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 ...
随机推荐
- Runtime之方法交换
在没有一个类的实现源码的情况下,想改变其中一个方法的实现,除了继承它重写.和借助类别重名方法暴力抢先之外,还有就是方法交换 方法交换的原理:在OC中调用一个方法其实是向一个对象发送消息,查找消息的唯一 ...
- FPGA CRC-16/XMODEM x16+x12+x5+1
module crc_16( input clk, input [47:0]mac, input rst, input hash_enable,//哈希控制器使能位 output reg hash_c ...
- Git 报错:Updates were rejected because the tip of your current branch is behind
刚开始学习 git 命令,发现会出现很多的错误,所以就总结下出现的错误,以此来加深理解和掌握吧! 环境:在本地库操作了一系列的 add 和 commit 操作后,想把本地仓库推送到远端,但是发生以下错 ...
- count(1),count(*)和count(列)的比较
转自:https://www.cnblogs.com/Caucasian/p/7041061.html 1.关于count(1),count(*),和count(列名)的区别 相信大家总是在工作中,或 ...
- 数字证书原理(ssl,https)
https://blog.csdn.net/qq_34115899/article/details/81298284 关于私钥公钥数字签名数字证书.https.RSA的一些讲解 http://www. ...
- java this的用法以及原理
/** * this存在方法中,在方法中被调用. * 且是非static方法中被调用.(this 表示这个类的当前实例,而静态方法不依赖于该类的任何实例,随着类产生而装载,因此方法内不能引用 this ...
- 提示Asp.net4.5未在web服务器上注册
在用vs2012代开项目时, 每回都显示Asp.net4.5未在web服务器上注册,最后是由于没有下载一个补丁的原因,只需要下载安装补丁 VS11-KB3002339.exe ,下载地址:https: ...
- 成为优秀Angular开发者所需要学习的19件事
一款to-do app基本等同于前端开发的"Hello world".虽然涵盖了创建应用程序的CRUD方面,但它通常只涉及那些框架或库也能做到的皮毛而已. Angular看起来似乎 ...
- 吴裕雄--天生自然 JAVA开发学习:运算符
public class Test { public static void main(String[] args) { int a = 10; int b = 20; int c = 25; int ...
- 01 语言基础+高级:1-2 面向对象和封装_day06【类与对象、封装、构造方法】
day06[类与对象.封装.构造方法] 面向对象类与对象三大特征——封装构造方法 能够理解面向对象的思想能够明确类与对象关系能够掌握类的定义格式能够掌握创建对象格式,并访问类中的成员能够完成手机类的练 ...