I am currently upgrading to Grails 4.1. In the past version I had a static mapping in my URL Mappings.groovy as follows:
class UrlMappings {
static mappings = {
name tool: "tool/$controller/$action?/$id?"{
"/$controller/$action?/$id?"{
constraints {
// apply constraints here
}
}
}
"/"(controller: "auth", action: "login")
"500"(view:'/error')
"404"(view:'/notFound')
}
}
This was working perfectly in previous Grails versions and when I click on a link to redirect to the url localhost:8000/tool/converters/list
, converter would be recognized as the Controller, list would be recognized as the Action and the correct view would be displayed. Now that I have upgraded, when I click on the link, the url that it redirect to is localhost:8080/tool%2Fconverters/list
and the error message "This page isn't working" is what is displayed in the view. The "%2F" somehow gets inserted into the url and is causing the page to not display.
I have looked at the Grails 4 documentation and I don't see any indication that the format for static mappings in the URL Mappings has changed. Does anyone have any idea as to why this is happening and how I can fix it?
See the project at https://github.com/jeffbrown/rookycodermapping.
package rookycodermapping
class SchemaController {
def show() {
render 'This is being rendered by the show action in SchemaController.'
}
}
package rookycodermapping
class UrlMappings {
static mappings = {
name tool: "/tool/$controller/$action?/$id?" {}
"/"(view:"/index")
"500"(view:'/error')
"404"(view:'/notFound')
}
}
<p>
Click <g:link action="show" controller="schema">here</g:link> to invoke the show action (g:link action="show" controller="schema").
Click <g:link uri="/tool/schema/show">here</g:link> to invoke the show action (g:link uri="/tool/schema/show").
</p>
Both of those links appear to work as expected.