pringMVC的handler接收如下的ServletAPI类型的参数:
• HttpServletRequest • HttpServletResponse • HttpSession • java.security.Principal • Locale • InputStream • OutputStream • Reader • Writer
示例:
@RequestMapping("/testServletAPI") public void testServletAPI(HttpServletRequest request, HttpServletResponse response, Writer out) throws IOException { System.out.println("testServletAPI: " + request + "," + response); out.write("hello springmvc"); } 对应的jsp: <a href="test/testServletAPI">Test ServletAPI</a>
运行项目,点击超链接:
控制台输出:
testServletAPI: org.apache.catalina.connector.RequestFacade@21f0bb9b,org.apache.catalina.connector.ResponseFacade@7d161