学习SpringMVC(五)之使用Servlet原生API

可以使用Servlet原生API作为目标方法的入参,具体类型有以下几种:

1.HttpServletRequest

2.HttpServletResponse

3.HttpSession

4.Writer

5.Reader

6.OutputStream

7.InputStream

8.java.security.Principal

在controller中:

@RequestMapping(value="/springmvc")
@Controller
public class MyServletAPI {
	
	@RequestMapping(value="testServletAPI")
	public void testServletAPI(HttpServletRequest request,HttpServletResponse response,Writer out) throws IOException{
		System.out.println("testServletAPI"+request+response+out);
		out.write("springmvc testServletAPI");
		//return "hello";
		
	}

}
在index.jsp中

  Test ServletAPI



你可能感兴趣的:(Spring,MVC,Spring,MVC从零开始,springmvc,servletAPI)