前面已经了解了Controller的几种配置方式
今天主要写一下响应界面跳转的几种方式
1.在注解的方式中
1.1通过HttpServletResponse的API直接输出(不需要配置渲染器)
controller类的主要代码
@Controller
public class RequestController{
@RequestMapping("/resp")
public void handleRequest(HttpServletRequest req, HttpServletResponse resp) throws Exception {
resp.getWriter().println("hello HttpServletResponse");
}
web.xml配置
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
dispatcher
org.springframework.web.servlet.DispatcherServlet
1
dispatcher
/
dispatcher-servlet.xml主要代码
xmlns:context="http://www.springframework.org