Allen_Zsj

导航

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

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

代码示例:

index.jsp:

<a href="springmvc/testServletAPI"> test ServletAPI</a>

@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;
}

posted on 2017-12-21 14:37  Allen_Zsj  阅读(123)  评论(0编辑  收藏  举报