Selvakumar Ponnusamy
Selvakumar Ponnusamy

Reputation: 5533

Generate URL with Query String in Play framework templates

I'm using play 1.1, I have a URL mapping routes file as,

* /show/{id}/ TestController.show

and TestController is specified as

public static void show(String id){}

When I use above route in my HTML template by @{TestController.show(id)}, I would expect to render as /show/23/ in the browser address bar, but like this instead its rendered as default mapping(/TestController/show?id=23) which has least priority in routes file. Can you please help me how do we render the URL as http://localhost:9000/show/23/?

Upvotes: 2

Views: 1075

Answers (1)

biesior
biesior

Reputation: 55798

The actions arguments has to be the same type as these passed in template so if you built href in template with @{TestController.show(id)} where id is porbably type of Long or int declare your action with the same argument.

public static void show(Long id){
  ... action's body ...
} 

Upvotes: 1

Related Questions