user2427
user2427

Reputation: 7932

Grails UrlMappings with "-" as a separator

I want to separate String params with a "-" in a url.

I had configurate UrlMappings with:

name friendlyurl: "/${productId}-${title}_url"{
  controller = "product"
  action = "index"
}

The productId is in the form stringnumber, like ESE123

The product controller needs the param productId. It works with url like:

ESE1234-asdlashdlasj_url

But not with

ESE1234-Adidas-shoes_url

In the last case it take ESE1234-Adidas as a productId.

Maybe grails is using eager regexp matcher.

How to I disable this eager regexp in order to only take to the first "-"? Or maybe other way maybe.

Upvotes: 0

Views: 217

Answers (1)

Aaron Saunders
Aaron Saunders

Reputation: 33345

why dont you just do

name friendlyurl: "/${productId}/${title}_url"{
  controller = "product"
  action = "index"
}

and if the "-" is so important, just concat it back together in the controller

Upvotes: 2

Related Questions