RSM
RSM

Reputation: 433

URL mapping in Grails

Suppose this is my URL:

https://stackoverflow.com/questions/ask/question1.xml

Currently in my UrlMappings.groovy I have `

"/$Question/$ask/$question1"(controller:"somecontroller")` to handle the request.

If my URL changes to:

https://stackoverflow.com/questions/ask/askAgain/question1.xml

my URL mapping cannot handle it.

Is there a way I can get ask/askAgain to be referenced by $ask in my urlmapping.groovy?

Upvotes: 1

Views: 967

Answers (2)

RSM
RSM

Reputation: 433

This is what I did to get around this. I changed my URLMapping to

"/$Question/$ask**"(controller:"somecontroller")

If my URL is :

`http://stackoverflow.com/questions/ask/askAgain/question1.xml`

So now, $ask** = ask/askAgain/question1.xml

Then, If I want to remove question1.xml from that URL. I can use Regex to get rid of it.

Upvotes: 2

dmahapatro
dmahapatro

Reputation: 50275

You will have to provide 2 mappings:

"/$Question/$ask/$question1"(controller: "somecontroller")
"/$Question/$ask/$askAgain/$question1"(controller: "somecontroller")

Upvotes: 1

Related Questions