I'm working on a java web application with play framework 1.2.4. In my view, I try to invoke a method in the controller but it doesn't work. Here is the view code :
%{ url='/'+lang+'/artists/item?.name?.asString()+'-'+item?.id?.asString(); }%
<a href="${url}"></a>
So the url is something like localhost:9000/en/artists/artistName-artistId
,
for the action code :
public static void artistView(String lang, String artistName, String artistId, String mode) {
//my code here
}
the routes conf :
GET /{<(fr)|(en)|(ar)>lang}/artists/{artistName}-{<[0-9]{32}>artistId} MyControllerName.artistView(mode:'overview')
With this, my action is never invoked. What did I do wrong ? Thanks in advance.
First, I see your URL is wrong, it should be:
Anyway, I think you can fix it.
Second, I think you want your artistId is the number from 1 character to 32 characters, not exactly 32 characters.
So, route.conf should be:
Please read more about Regular Expression if you want to know why?
Note:
(mode:'overview')
will be no effect. If you want to set default, please do it in your controller like:Hope that help.