Reputation: 13208
I'm able to create html links the following way:
<a href="/about">About Us</a>
This will follow the routing for /about
. But on the following pages (I know it's for an earlier version of Play, but I couldn't find any info for 2.0.1):
http://www.playframework.org/documentation/1.1/tags
playframework how to call method from html in href that takes one parameter?
The link is obtained from the routing file. I have the routing for the above link defined as:
GET /about controllers.Application.about()
In PlayFramework2, how can I programmatically get the routing to happen by passing in the controller and function name?
Upvotes: 2
Views: 741
Reputation: 55798
Use this in the template:
<a href="@routes.Controller.method("param-value")">Link</a>
in your case:
<a href="@routes.Application.about()">Link</a>
also you can use router in the controller with similar syntax:
public static Result redirectSomwhere(){
return redirect(routes.Application.about());
}
Upvotes: 6