Spring Mvc Controller间跳转 重定向 传参 (转)
原文链接:http://zghbwjl.blog.163.com/blog/static/12033667220137795252845/
1. 需求背景
2. 解决办法
@RequestMapping("/save")
public String save(@ModelAttribute("form") Bean form,RedirectAttributes attr)
throws Exception {
String code = service.save(form);
if(code.equals("000")){
attr.addFlashAttribute("name", form.getName());
attr.addFlashAttribute("success", "添加成功!");
return "redirect:/index";
}else{
attr.addAttribute("projectName", form.getProjectName());
attr.addAttribute("enviroment", form.getEnviroment());
attr.addFlashAttribute("msg", "添加出错!错误码为:"+rsp.getCode().getCode()+",错误为:"+rsp.getCode().getName());
return "redirect:/maintenance/toAddConfigCenter";
}
}
@RequestMapping("/index")
public String save(@ModelAttribute("form") Bean form,RedirectAttributes attr)
throws Exception {
return "redirect:/main/list";
}
页面取值不用我说了吧,直接用el表达式就能获得到,这里的原理是放到session中,session在跳到页面后马上移除对象。所以你刷新一下后这个值就会丢掉。
3. 总结
Spring Mvc Controller间跳转 重定向 传参 (转)的更多相关文章
- spring mvc controller间跳转 重定向 传参(转)
spring mvc controller间跳转 重定向 传参 url:http://zghbwjl.blog.163.com/blog/static/12033667220137795252845/ ...
- spring mvc controller间跳转 重定向 传参 (转)
转自:http://zghbwjl.blog.163.com/blog/static/12033667220137795252845/ 1. 需求背景 需求:spring MVC框架contr ...
- spring mvc controller间跳转 重定向 传参
http://blog.csdn.net/jackpk/article/details/19121777/
- spring mvc controller间跳转 重定向
1. 需求背景 需求:spring MVC框架controller间跳转,需重定向.有几种情况:不带参数跳转,带参数拼接url形式跳转,带参数不拼接参数跳转,页面也能显示. 本来以为挺简单的一 ...
- springMVC controller间跳转 重定向 传递参数的方法
springMVC controller间跳转 重定向 传递参数的方法 spring MVC框架controller间跳转,需重定向.有几种情况:不带参数跳转,带参数拼接url形式跳转,带参数不拼接参 ...
- flutter页面间跳转和传参-Navigator的使用
flutter页面间跳转和传参-Navigator的使用 概述 flutter中的默认导航分成两种,一种是命名的路由,一种是构建路由. 命名路由 这种路由需要一开始现在创建App的时候定义 new M ...
- MVC中学到的小知识(MVC中的跳转,传参)
1.mvc中视图中的href="XXX",这个XXX是控制器地址,不是另一个视图.(这里的href语句只能转向控制器,不能直接转向视图),如果要实现转向视图,可以先转到控制器,然后 ...
- Flutter 路由 页面间跳转和传参 返回
Navigator Navigator用来管理堆栈功能(即push和pop),在Flutter的情况下,当我们导航到另一个屏幕时,我们使用Navigator.push方法将新屏幕添加到堆栈的顶部.当然 ...
- Spring mvc框架 controller间跳转 ,重定向 ,传参
一.需求背景 1. 需求:spring MVC框架controller间跳转,需重定向.有几种情况:不带参数跳转,带参数拼接url形式跳转,带参数不拼接参数跳转,页面也能显示. @Req ...
随机推荐
- cocos2d-x触屏事件(单点触屏)
转自:http://blog.csdn.net/onerain88/article/details/7550009 一般经常用到的触屏的情况有两种:一种是Layer统一接收触屏消息,然后由程序根据需要 ...
- jQuery Mobile方向感应事件
在现在的智能手机中,都有对方向变换的自动感知功能,比如当手机方向从水平方向切换到垂直方向时,则会触发该事件.在jQuery Mobile中,可以通过orientationchange事件进行绑定,并且 ...
- ubuntu12.04的vim配置
ubuntu12.04中使用的vim的版本不支持像语法高亮和文件类型检测等配置 #sudo apt-get install vim vim默认的配置使用起来还不能让人满意,还需要自己配置默认配置文件是 ...
- contentProvider模板
package com.example.qunzheng.todolist.provider; import android.content.ContentProvider; import andro ...
- Some current MySQL Architecture writings
Posted on 19/09/2014 by Stewart Smith So, I’ve been looking around for a while (and a few times now) ...
- 系统调用服务号 linux 2.6.32
http://www.cnblogs.com/xcywt/p/4998963.html 系统定义符号集中声明在 /usr/src/kernels/linux-2.6.32/include/linux/ ...
- java.sql.SQLException: Lock wait timeout exceeded --转
org.springframework.dao.CannotAcquireLockException 的解决> 直接上 bug 的详细信息: 2012-03-12 15:20:31 XmlBea ...
- java class 文件解析
参考下面两个文章对一个class文件进行解析: http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.4.6 htt ...
- zepto的scrollTo,实现锚点跳转
实现功能:点击右侧字母A,实现锚点跳转功能: 有同学可能说可以直接用锚点跳转实现,是的,锚点跳转可以实现这个功能,但是有一个问题,点击跳转后,再点击返回,返回的是上次跳转的结果,具体的原理就不用多说了 ...
- Java read()和readLine()的区别
1.read() 功能:读取单个字符的个数,如果已经读完的话会返回-1 (其范围从 0 到 65535 ) 例子如下: byte[] buf = new byte[1024]; int len; wh ...