SpringMVC的forward和redirect
2015-05-22 01:10
447 查看
package com.pas.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @Controller public class LoginController { @RequestMapping(value = "/forward.do") public String forward(@RequestParam("userName") String userName, @RequestParam("password") String password, @RequestParam("role") String role) { System.out.println("Login....................................."); return "index";//使用forward方式 } @RequestMapping(value = "/redirect.do") public String redirect(@RequestParam("userName") String userName, @RequestParam("password") String password, @RequestParam("role") String role) { System.out.println("Login....................................."); return "redirect:index.jsp";//重定向方式 } }
或者这种方式:
public ModelAndView login(@RequestParam("userName") String userName, @RequestParam("password") String password, @RequestParam("role") String role) { System.out.println("Login....................................."); ModelAndView view = null; if (StringUtils.equalsIgnoreCase("pandy", userName) && StringUtils.equalsIgnoreCase("pandy", password)) { view = new ModelAndView(new RedirectView("index.jsp")); } else { view = new ModelAndView("../login"); } return view; }
相关文章推荐
- springMVC中的redirect和forward跳转
- SpringMvc(4-1)Spring MVC 中的 forward 和 redirect(转)
- SpringMVC的forward和redirect
- 《Spring实战》读书笔记--SpringMVC之forward与redirect
- 《Spring实战》读书笔记--SpringMVC之forward与redirect
- Springmvc 在同一个controller和不同的controller中进行重定向redirect和转发forward:
- SpringMVC 控制器中方法之间的跳转(客户端跳转(redirect)和服务器端跳转(forward))
- springmvc中forward和redirect
- springmvc:Forward和Redirect
- Springmvc 在同一个controller和不同的controller中进行重定向redirect和转发forward
- springmvc中forward和redirect
- 【SpringMVC】 forward 和 redirect
- springmvc中forward和redirect
- SpringMVC中使用forward和redirect进行转发和重定向以及重定向时如何传参详解
- springmvc中使用forward和redirect
- SpringMVC-forward和redirect
- SpringMVC 中Controller之间的 forward 和 redirect
- SpringMVC 的redirect 和forward 跳转
- springmvc中使用forward和redirect
- 项目记录:springmvc forward redirect 问题