SpringMVC 支持使用Servlet原生API作为目标方法的参数

具体支持一下类型:
* HttpServletRequest
* HttpServletResponse
* HttpSession
* java.security.Pricipal
* Locale
* InputStream
* OutputStream
* Reader
* Writer

代码示例:

index.jsp:

test ServletAPI

@Controller:

@RequestMapping("/testServletAPI")
public void testServletAPI(HttpServletRequest request,HttpServletResponse response,Writer w) throws IOException{
System.out.println("testServletAPI request: " + request + ",response: " + response);
w.write("Hello SpringMVC!");
// return SUCCESS;
}

转载于:https://www.cnblogs.com/Allen-Zsj/p/8080472.html

你可能感兴趣的:(java)