Grails Controller - redirect 方法
官方文档:
网页跳转方法1:
// 在一个Action中直接跳转到另外一个Action中,另外的Action接受一个opportunity对象,这里直接通过id传过去就行,约定规则,就可以获取对应内容。
redirect controller: "opportunity", action: "show", id: opportunityContract.opportunity.id
// 在一个Action中直接跳转到另外一个Action中,另外的Action接受一个opportunity对象,这里直接通过id传过去就行,约定规则,就可以获取对应内容。
redirect controller: "opportunity", action: "show", id: opportunityContract.opportunity.id
网页跳转方法2:
// Opportunity的show.gsp页面
http://localhost:8080/opportunity/show/56829
// RightCentification的Create Action:
def create()
{
params['targetUri'] = request.getHeader("referer") // 存放到params里面
respond new RightCertification(params)
}
// RightCentification的Create 页面,放到表单里面,再传递给后面Save Action:
http://localhost:8080/rightCertification/create?opportunity=56829
<g:hiddenField name="targetUri" value="${params?.targetUri}"></g:hiddenField>
// RightCentification的 Save Action就可以直接跳转回Opportunity的show.gsp页面
redirect url: params['targetUri']
x
// Opportunity的show.gsp页面
http://localhost:8080/opportunity/show/56829
// RightCentification的Create Action:
def create()
{
params['targetUri'] = request.getHeader("referer") // 存放到params里面
respond new RightCertification(params)
}
// RightCentification的Create 页面,放到表单里面,再传递给后面Save Action:
http://localhost:8080/rightCertification/create?opportunity=56829
<g:hiddenField name="targetUri" value="${params?.targetUri}"></g:hiddenField>
// RightCentification的 Save Action就可以直接跳转回Opportunity的show.gsp页面
redirect url: params['targetUri']
Grails Controller - redirect 方法的更多相关文章
- Grails Controller - respond 方法
基本用法 官方文档:http://docs.grails.org/latest/ref/Controllers/respond.html 为当前 respond 语句所在 action 所对应的页面返 ...
- springmvc中controller内方法跳转forward?redirect?
使用springmvc的controller的时候,碰到controller内方法的跳转的问题,记录下问题以及自己测试的过程. 场景: 业务执行更新操作之后返回列表页面,列表页面需默认展示查询的列表数 ...
- 在MVC里面使用Response.Redirect方法后记得返回EmptyResult
在ASP.NET MVC中我们很多时候都会在拦截器和Controller中直接使用Response.Redirect方法做跳转,但是实际上Response.Redirect方法执行后ASP.NET并不 ...
- thinkphp3.2.3中U()方法和redirect()方法区别
今天博主看3.1的教程,学着3.2,就遇到了这个坑,怎么就是不跳转呢,很纳闷!! 在thinkphp3.1 中 U()方法是可以执行跳转的(看视频教程里面是可以的,博主没有测试过). 但是在think ...
- 如何解决Response.Redirect方法传递汉字丢失或乱码问题?
为了确保传递的汉字被正确地接收,可以在传值之前使用Server对象的UrlEncode方法对所传递的汉字进行URL编码.代码如下: String name = Server.UrlEncode(&qu ...
- 详解SpringMVC中Controller的方法中参数的工作原理[附带源码分析]
目录 前言 现象 源码分析 HandlerMethodArgumentResolver与HandlerMethodReturnValueHandler接口介绍 HandlerMethodArgumen ...
- 重定向语句Response.Redirect()方法与Response.RedirectPermanent()对搜索引擎页面排名的影响
在ASP.NET中,开发人员经常使用Response.Redirect()方法,用编程的手法,将对老的URL的请求转到新的URL上.但许多开发人员没有意识到的是,Response.Redirect() ...
- Navigation Controller 创建方法
添加Navigation Controller的方法主要有两种: 第一种:主要是通过在storyboard中拖入Object library 中的Navigation Controller 第二种方法 ...
- 【异常处理】Springboot对Controller层方法进行统一异常处理
Controller层方法,进行统一异常处理 提供两种不同的方案,如下: 方案1:使用 @@ControllerAdvice (或@RestControllerAdvice), @ExceptionH ...
随机推荐
- 查看docker的挂载目录
docker inspect container_name | grep Mounts -A 20docker inspect container_id | grep Mounts -A 20
- 洛谷 P2722 总分 Score Inflation && 完全背包模板
题目传送门 解题思路: 补一个完全背包的模板,跟01背包十分相似,唯一不同在于重量j的枚举顺序. AC代码: #include<cstdio> #include<iostream&g ...
- navicat for mysql连接数据库报错1251
使用Navicat for mysql 连接数据库,报如下错误 原因:数据库安装的是8.0版本,新的mysql采用了新的加密方式,导致连接失败 解决办法:数据库执行如下命令 改密码加密方式:用管理员身 ...
- JNI的第2种写法:本地方法注册
声明:迁移自本人CSDN博客https://blog.csdn.net/u013365635 孔乙己说,茴香豆的茴有四种写法,今天谈谈JNI的第2种写法:本地方法注册. 这种写法的好处是不需要使用ja ...
- springboot cloud 网盘
boot https://pan.baidu.com/s/12SkGJNu_M-I-pjg-GxqHRw 5uga boot-cloud https://pan.baidu.com/s/1gO ...
- oracle 学习(四)游标
显式游标 隐式游标:如果在PL/SQL程序段中使用SELECT语句进行操作,PL/SQL 会隐含的处理游标定义,即为隐式游标.这种游标不需要像显式那样声明,也不必打开关闭. CREATE OR REP ...
- 关于live2D的使用
<script src="https://eqcn.ajz.miesnfu.com/wp-content/plugins/wp-3d-pony/live2dw/lib/L2Dwidge ...
- Linux文件共享的实现方式
前两天跟老师去北京开了一个会议,好久没学习了,今天才回学校,其中的辛酸就不说了.来正文: 1.什么是文件共享 (1).文件共享就是同一个文件(同一个文件指的是同一个inode,同一个pathname) ...
- POJ 1O17 Packets [贪心]
Packets Description A factory produces products packed in square packets of the same height h and of ...
- Microsoft.Office.Inter.Excel.dll在調用時可能會出現如下錯誤
Microsoft.Office.Inter.Excel.dll在調用時可能會出現如下錯誤,具體解決方案如下: 1. 錯誤資訊:檢索 COM 類工廠中 CLSID 為{00024500-0000-00 ...