2015-06-14 58 views
1

如何在超链接点击时继承参数?Grails:对超链接进行params点击

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

如何发扬超链接被点击时的参数?

回答

1

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

问题是你没有通过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>