Domanda

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

È stato utile?

Soluzione

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') {
    ...
  }
}

Altri suggerimenti

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top