SpringMVC之使用Servlet原生API作为参数
SpringMVC的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@7d1613c6
本文来自博客园,作者:Javanumberone,转载请注明原文链接:https://www.cnblogs.com/stm32stm32/p/9093110.html
posted on 2018-05-26 15:50 Javanumberone 阅读(291) 评论(0) 编辑 收藏 举报