質問

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