Reputation: 1701
I am using Play 2.4 with Java, and I've got this route:
GET /page/:slug controllers.Application.page(slug: String)
So, for instance, if slug = this-is-a-slug
, there's no problem, the route looks like this:
/page/this-is-a-slug
But, if slug = first-part-of-the-slug/second-part-of-the-slug
, the URL bar shows:
/page/first-part-of-the-slug%2Fsecond-part-of-the-slug
I'd like to avoid encoding the slug, knowing that the number of slug 'parts' is undefined, and keep the slug as a unique parameter.
How could I do that? Any help appreciated.
Upvotes: 2
Views: 654
Reputation: 8263
You need to use "*" like:
/page/*slug
Look for the "Dynamic parts spanning several /" section in the documentation https://www.playframework.com/documentation/2.4.x/JavaRouting
If you want a dynamic part to capture more than one URI path segment, separated by forward slashes, you can define a dynamic part using the * id syntax, which uses the .* regular expression:
GET /files/*name controllers.Application.download(name)
Here, for a request like
GET /files/images/logo.png
, thename
dynamic part will capture theimages/logo.png
value.
Upvotes: 3