Problems with the Grails Namespace

I'm having problems redirecting Grails to namespaces:

I have this redirect in LoginController:

redirect(namespace:'auth',controller:'login',action: "login")

and this is defined in my urls:

"/auth/$action?/$id?" {
 controller = 'login'
 namespace = 'auth'
 }

However, redirection does not work, it redirects: login / login, not auth / login.

Also, the login form is created with the login / authenticate action, not auth / authenticate.

Any ideas?

This is Grails 2.3.4 btw.

Thanks.

+4
source share
2 answers

The solution that worked for me was to use the name of the url :

1) specify the name of the mapping in your UrlMappings.groovy:

name specialLoginMapping: "/auth/$action?/$id?" {
 controller = 'login'
 namespace = 'auth'
}

2) reference this mapping in your redirect call

redirect(mapping: 'specialLoginMapping', action: 'login')

Grails / UrlMappings

0

UrlMappings.groovy:

"/auth/$controller/$action?/$id?" {
   namespace = 'auth'
}

, url:

<g:form url="[action:'save', namespace:'auth']">
.......
</g:form>
0

Source: https://habr.com/ru/post/1527039/


All Articles