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: [email protected],[email protected]
原文地址:https://www.cnblogs.com/stm32stm32/p/9093110.html
时间: 2024-09-29 18:06:09