문제

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