首页 > 其他 > 详细

Grails Controller - redirect 方法

时间:2019-11-11 13:03:17      阅读:107      评论:0      收藏:0      [点我收藏+]

官方文档:

网页跳转方法1:

// 在一个Action中直接跳转到另外一个Action中,另外的Action接受一个opportunity对象,这里直接通过id传过去就行,约定规则,就可以获取对应内容。
redirect controller: "opportunity", action: "show", id: opportunityContract.opportunity.id
 
1
// 在一个Action中直接跳转到另外一个Action中,另外的Action接受一个opportunity对象,这里直接通过id传过去就行,约定规则,就可以获取对应内容。
2
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
 
1
// Opportunity的show.gsp页面
2
http://localhost:8080/opportunity/show/56829
3
4
// RightCentification的Create Action:
5
def create()
6
{
7
    params[‘targetUri‘] = request.getHeader("referer") // 存放到params里面
8
    respond new RightCertification(params)
9
}
10
11
// RightCentification的Create 页面,放到表单里面,再传递给后面Save Action:
12
http://localhost:8080/rightCertification/create?opportunity=56829
13
<g:hiddenField name="targetUri" value="${params?.targetUri}"></g:hiddenField>
14
15
//  RightCentification的 Save Action就可以直接跳转回Opportunity的show.gsp页面
16
redirect url: params[‘targetUri‘]
17

Grails Controller - redirect 方法

原文:https://www.cnblogs.com/duchaoqun/p/11834097.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!