Spring MVC 的视图转发

Spring MVC 默认采用的是转发来定位视图,如果要使用重定向,可以如下操作

 

1、使用RedirectView

1 public ModelAndView login(){  
2    RedirectView view = new RedirectView("login.do");  
3    return new ModelAndView(view);  
4 } 

2、使用redirect:前缀

1 public String login(){  
2     //TODO  
3     return "redirect:login.do";  
4 }  

 

posted @ 2016-05-30 14:21  npe0  阅读(337)  评论(0)    收藏  举报