I am new to grails. My need is to append value to url such that... from a controller, on succes of some action redirect to new url usingredirect function redirect(uri: "/login/auth") .But my actual need is the resulting url should be like this /login/auth?successMessage=Created ,so that i can take the value of successMessage in the resulting uri. so inorder to do this action what changes must be done in the redirection function of my above controller

有帮助吗?

解决方案

You can use the params parameter of redirect which takes a map of parameters that get appended to the url.

E.g.:

redirect controller: 'login', action: 'auth', params: [successMessage: 'Created']

/edit:

To answer the question in the comments (in this case how can i compare value of successMessage in new url?):

Within the controller you can then check the value of successMessage using params.successMessage:

def myAction() {
  if (params.successMessage == 'Created') {
    ...
  }
}

其他提示

You might want to put the code above into an after-interceptor

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top