spring mvc三种controler的写法

其实在spring 3.0,4.0以前,是有三种写controler的方法的复习下,不过一般最后一种方法最多了:
 

1
 

public class ControllerDemo2 implements Controller {

    public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
       ModelAndView mv = new ModelAndView();
       mv.setViewName("success2");

        return mv;
    }

2 第二种写法:
 

public class ControllerDemo3 implements HttpRequestHandler {

    public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.getRequestDispatcher("/WEB-INF/pages/success3.jsp").forward(request,response);
        return;
    }


这样的话,其实在XML中是要配置的:
 

   

    
                    

你可能感兴趣的:(JAVA)