Grails:单击超链接上的继承参数

Grails: Carry forward params on hyperlink is clicked

点击超链接时参数如何结转?

这是我的 gsp 代码:

<g:link class="grid_link" controller="user" action="delete" id="${userInstance.id}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure, want to delete?')}');">Delete</g:link>

这是我的控制器代码:

def delete() {
    try {
        def userInstance = User.get(params.id)

        //deleting the user
        //successful.

        redirect(action: "list", params: params)
    } catch (Exception e) {
        log.error("Deleted Exception---->>" + e.getMessage())
    }
}

params 缺少重定向。我想在 redirect 上推进 params

我点击 'delete' 超链接之前的 URL 看起来像:

http://localhost:8080/message/list?offset=10&max=100

单击 'delete' 超链接后,url 看起来像:

http://localhost:8080/message/list/11

点击超链接时参数如何结转?

如果您查看重定向的 URL,您会发现 params 已正确转发。 11 您在删除操作中唯一的 params 并且在成功删除后转发到列表操作 (.../list/11)。

问题是您没有通过 delete 调用传递 maxoffset。将您的 link 更改为

<g:link params="${params}" class="grid_link" controller="user" action="delete" id="${userInstance.id}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure, want to delete?')}');">Delete</g:link>