1.哪些可以使用

  MVC中的Handler方法可以接受ServletAPI类型的参数。

  

2.controller

 package com.spring.it;

 import java.io.IOException;
import java.io.Writer; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; @Controller
public class ServletApiControl {
@RequestMapping("/helloworld6")
public void hello(HttpServletRequest request,HttpServletResponse response,Writer out) throws Exception {
System.out.println("request="+request);
System.out.println("response="+response);
out.write("Spring mvc");
}
}

3.index

 <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<br>
<a href="helloworld6/">test servlet API</a>
</body>
</html>

4.效果

  

5.ps

  Writer的由来

  response.getWriter();

009 使用servlet API作为参数的更多相关文章

  1. struts2 笔记01 登录、常用配置参数、Action访问Servlet API 和设置Action中对象的值、命名空间和乱码处理、Action中包含多个方法如何调用

    Struts2登录 1. 需要注意:Struts2需要运行在JRE1.5及以上版本 2. 在web.xml配置文件中,配置StrutsPrepareAndExecuteFilter或FilterDis ...

  2. springmvc使用pojo和servlet原生api作为参数

    一.Pojo作为参数: 实体: package com.hy.springmvc.entities; public class User { private String username; priv ...

  3. 笔记01 登录、常用配置参数、Action访问Servlet API 和设置Action中对象的值、命名空间和乱码处理、Action中包含多个方法如何调用

    Struts2登录 1. 需要注意:Struts2需要运行在JRE1.5及以上版本 2. 在web.xml配置文件中,配置StrutsPrepareAndExecuteFilter或FilterDis ...

  4. SpringMVC(十三) RequestMapping 使用servlet原生API作为参数

    SpringMVC支持以下Servlet方法: HttpServletRequest HttpServletResponse HttpSession Writer Reader Locale Inpu ...

  5. Struts2中获取servlet API的几种方式

    struts2是一个全新的MVC框架,如今被广大的企业和开发者所使用,它的功能非常强大.这给我们在使用servlet 纯java代码写项目的时候带来了福音.但是一般来说,我们的项目不到一定规模并不需要 ...

  6. Servlet API遍程常用接口和类

    本文主要总结Servlet  API遍程常用接口和类 Servlet API http://tomcat.apache.org/tomcat-5.5-doc/servletapi/index.html ...

  7. 【SpringMVC】SpringMVC系列8之Servlet API 作为入参

    8.Servlet API 作为入参 8.1.概述 MVC 的 Handler 方法可以接受哪些 ServletAPI 类型的参数: HttpServletRequest HttpServletRes ...

  8. Struts2 Action与Servlet API耦合

    单元测试在开发中是非常重要的一个环节程序员在写完代码时,相应的单元测试也应写完整,否则你的代码就是不能让人信服的Struts2将Action与Servlet的API进行解耦之后,就使得单元测试变得非常 ...

  9. Action访问Servlet API

    访问Servlet API 1.通过ActionContent类访问Servlet API ActionContext中访问Servlet API的几个常用的方法: (1)Map getApplica ...

随机推荐

  1. JQuery 的Bind()事件

    刚开始我们先看一下它的定义: .bind( eventType [, eventData], handler(eventObject)) .Bind()方法的主要功能是在向它绑定的对象上面提供一些事件 ...

  2. extern的作用

    #include <stdio.h>extern int a;static int a;extern int b;int b;static int c;extern int c;

  3. python 新式类的 __getattribute__

    这个方法定义在object中,所以所有的新式类都继承有该方法,所有的新式类的实例在获取属性value的时候都会调用该方法,为了验证这一结论,我们重写一下该方法: class C(object): a ...

  4. Two Sum I & II & III & IV

    Two Sum I Given an array of integers, find two numbers such that they add up to a specific target nu ...

  5. EB-GAN系(Energy-based GAN)

    学习总结于国立台湾大学 :李宏毅老师 EB-GAN: Energy-based Generative Adversarial Network MA-GAN:MAGAN: Margin Adaptati ...

  6. lxde 的安装和卸载以及注意事项,lubuntu

    安装: $ sudo apt install lxde $ sudo apt install lxde-common 安装完毕后,可能没法关机及logout,可以使用如下安装: $ sudo apt ...

  7. ubuntu 的 apt-get update 出现404错误时,或者添加ppa失败时,ubuntu 版本也 end of life 了的解决方案

    xmodulo.com/how-to-fix-apt-get-update-error-on-ubuntu.html 如果是依赖没找到,可以用 sudo apt-get install -f 先补齐依 ...

  8. C++ virtual函数重写,在继承的时候没有在函数前写virtual关键字也依然是虚函数吗?

    比如: class Base { Base() {}; ~Base() {}; virtual void Init(); }; class Derived:public Base { virtual ...

  9. select 不要 用*

    背景 说实在的,这有什么好记录的呢.记录这个有啥用,真是技术人员的吹毛求疵.说起来,就是给人装有用吧.既然记录了,也想个相关的段子吧.曾经有个同事写了个sql,效率极差,来了个女同事,竟然解决了,问题 ...

  10. 001_vagrant利器

    一. 这是一个关于Vagrant的学习系列,包含如下文章: Vagrant入门 http://www.cnblogs.com/davenkin/p/vagrant-virtualbox.html 创建 ...