spring MVC controller中的方法跳转到另外controller中的某个method的方法
return new ModelAndView("redirect:/toList");这样可以重定向到toList这个方法
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在跳到页面后马上移除对象。所以你刷新一下后这个值就会丢掉。
spring MVC controller中的方法跳转到另外controller中的某个method的方法的更多相关文章
- spring mvc:内部资源视图解析器2(注解实现)@Controller/@RequestMapping
spring mvc:内部资源视图解析器2(注解实现) @Controller/@RequestMapping 访问地址: http://localhost:8080/guga2/hello/goo ...
- Spring MVC 使用介绍(十五)数据验证 (二)依赖注入与方法级别验证
一.概述 JSR-349 (Bean Validation 1.1)对数据验证进一步进行的规范,主要内容如下: 1.依赖注入验证 2.方法级别验证 二.依赖注入验证 spring提供BeanValid ...
- Spring MVC 3 表单中文提交post请求和get请求乱码问题的解决方法
在spring mvc 3.0 框架中,通过JSP页面.HTML页面以POST方式提交表单时,表单的参数传递到对应的servlet后会出现中文显示乱码的问题.解决办法可采用spring自带的过滤技术, ...
- Android开发中使用Intent跳转到系统应用中的拨号界面、联系人界面、短信界面
现在开发中的功能需要直接跳转到拨号.联系人.短信界面等等,查找了很多资料,自己整理了一下. 首先,我们先看拨号界面,代码如下: Intent intent =new Intent(); intent. ...
- spring mvc controller间跳转 重定向 传参(转)
spring mvc controller间跳转 重定向 传参 url:http://zghbwjl.blog.163.com/blog/static/12033667220137795252845/ ...
- HandlerMethodArgumentResolver(一):Controller方法入参自动封装器【享学Spring MVC】
每篇一句 你的工作效率高,老板会认为你强度不够.你代码bug多,各种生产环境救火,老板会觉得你是团队的核心成员. 前言 在享受Spring MVC带给你便捷的时候,你是否曾经这样疑问过:Control ...
- Spring MVC 中使用AOP 进行统一日志管理--XML配置实现
1.介绍 上一篇博客写了使用AOP进行统一日志管理的注解版实现,今天写一下使用XML配置实现版本,与上篇不同的是上次我们记录的Controller层日志,这次我们记录的是Service层的日志.使用的 ...
- 针对spring mvc的controller内存马-学习和实验
1 基础 实际上java内存马的注入已经有很多方式了,这里在学习中动手研究并写了一款spring mvc应用的内存马.一般来说实现无文件落地的java内存马注入,通常是利用反序列化漏洞,所以动手写了一 ...
- Spring MVC 中使用 Google kaptcha 验证码
验证码是抵抗批量操作和恶意登录最有效的方式之一. 验证码从产生到现在已经衍生出了很多分支.方式.google kaptcha 是一个非常实用的验证码生成类库. 通过灵活的配置生成各种样式的验证码,并将 ...
随机推荐
- PowerDesigner表生成 EXCEL
今天收到一个需求,要把数据库设计给一个excel版本的,百度出来一个脚本文件,很好用发现,留个纪念 在pd中,shift+ctrl+X,打开脚本运行,脚本如下,附件也留了一份: '********** ...
- linux 安装SAMtools,bcftools,htslib,sratoolkit,bedtools,GATK,TrimGalore,qualimap,vcftools,bwa
--------------------安装Samtools---------------------------------------------------------------------- ...
- 兼容多浏览器的网页复制插件(ZeroClipboard)
前言: 常规利用JS编写的网页复制功能是最简单的方法,但是只对IE有效,无法做到兼容其它浏览器,对其他浏览器也就只能弹窗提示用户手动复制了. <script type="text/ja ...
- [leetcode]125. Valid Palindrome判断回文串
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
- [leetcode]299. Bulls and Cows公牛和母牛
You are playing the following Bulls and Cows game with your friend: You write down a number and ask ...
- EditTex
<EditText android:layout_width="match_parent" android:layout_height="100dp" a ...
- VC++ 定时器使用总结
VC++ WM_TIMER 定时器使用方法 在编程时,会经常使用到定时器.使用定时器的方法比较简单,通常告诉Windows一个时间间隔,然后WINDOWS以此时间间隔周期性触发程 ...
- ADF学习实用网站
ADF中所有组件工功能例子 http://jdevadf.oracle.com/adf-richclient-demo/faces/components/dialog.jspx;jsessionid= ...
- Django配置Bootstrap, js
1.首先在APP目录下创建一个static文件夹 如图: # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'dj ...
- ubuntu查找命令比较
1. find find是最常见和最强大的查找命令,你可以用它找到任何你想找的文件. find的使用格式如下: $ find <指定目录> <指定条件> < ...