how to differentiate grails url mappings

441 Views Asked by At

I have the mappings:

"/$controller/$action?/$id?"{
            constraints {
                // apply constraints here
            }
        } // i used scaffolding and i think this is required by the generated stuff
'/'(controller:'home') //for the home page
'/$param1?/$param2?'(controller:'search') //for a search page 

The required url to be displayed in the browser is:
www.site.com/ - for home

www.site.com/keyword1/keyword2 - for a search by these optional keywords

This seems to work but my question is: Can I expect this to be correct or in some situation grails will get things mixed up?

1

There are 1 best solutions below

1
On BEST ANSWER

It will not. Grails will sort your url mappings based on a given set of precedence rules ( from specific to general ).

Your urls will always be the same and return the same page.

However, because your mappings are ambigous, sometimes it might return a page that you don't expect. A better design is to have search be mapped to:

/search/params1?/params2?

this way it is unambigous.