springMVC3学习(九)--redirect和forward跳转
来源:互联网 发布:盘古数据科技有限公司 编辑:程序博客网 时间:2024/06/07 03:36
springMVC3redirectforward
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- @Controller
- public class Login{
- /**转发**/
- @RequestMapping("/login.do")
- public String login(HttpServletRequest request,HttpServletResponse
- response){
- request.setAttribute("message","hello");
- return "forward:/index.do"; //forward在跳转后可以取到message值
- }
- @RequestMapping("/index.do")
- public String index(HttpServletRequest request,HttpServletResponse
- response){
- return "welcome";
- }
- /**重定向**/
- @RequestMapping("/logout.do")
- public String logout(HttpServletRequest request,HttpServletResponse
- response){
- request.setAttribute("message","hello");
- return "redirect:/register.do"; //redirect在跳转后无法取到message
- 值
- }
- @RequestMapping("/register.do")
- public String register(HttpServletRequest request,HttpServletResponse
- response){
- return "register";
- }
- }
另外forward跳转后地址栏URL不会改变 而redirect会改变
测试URL:
http://localhost:8080/spring_forward/login.do
http://localhost:8080/spring_forward/logout.do
0 0
- springMVC3学习(九)--redirect和forward跳转
- springMVC3学习(九)--redirect和forward跳转
- springMVC3学习(九)--redirect和forward跳转
- springMVC3学习(九)--redirect和forward跳转
- springMVC3学习(九)--redirect和forward跳转
- springMVC中的redirect和forward跳转
- SpringMVC 的redirect 和forward 跳转
- Servlet中的跳转(redirect和forward)
- 页面跳转之Forward和Redirect
- forward内部跳转 和redirect重定向跳转的区别
- forward内部跳转 和redirect重定向跳转的区别
- forward内部跳转 和redirect重定向跳转的区别
- forward内部跳转 和redirect重定向跳转的区别
- forward内部跳转 和redirect重定向跳转的区别
- forward内部跳转 和redirect重定向跳转的区别
- forward内部跳转 和redirect重定向跳转的区别
- forward内部跳转 和redirect重定向跳转的区别
- 服务器端与客户端跳转,forward和redirect总结
- mysql筛选指定时间段的数据,如三十天内的数据
- 整理常用正则表达式
- HDOJ 1394 求最小你序数
- 【学习笔记】关于struts2配置一两点
- 通俗理解LDA主题模型
- springMVC3学习(九)--redirect和forward跳转
- 快速开发Adapter
- GBK与UTF-8
- 毛泽东家族中为革命牺牲的六位英烈
- Makefile 中:= ?= += =的区别
- Remove Duplicates from Sorted Array
- grep
- 马尔科夫链MCMC采样算法和LDA Gibbs Sampling
- Convert Sorted List to Binary Search Tree