【问题标题】:Grails: Carry forward params on hyperlink is clickedGrails:点击超链接上的参数
【发布时间】:2015-06-14 08:46:45
【问题描述】:

点击超链接时如何将参数前移?

这是我的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

我点击“删除”超链接之前的 URL 如下所示:

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

点击“删除”超链接后,网址如下:

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

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

【问题讨论】:

    标签: grails redirect controller


    【解决方案1】:

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

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

    <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-01
      • 1970-01-01
      • 2011-11-06
      • 2011-06-07
      • 2012-12-10
      • 2012-10-21
      • 2017-03-29
      • 1970-01-01
      相关资源
      最近更新 更多