playframework how to call method from html in href

2019-07-07 08:51发布

I have the following routes

GET {company}.dev.alvazan.com/test  Web.test 
GET {company}.dev.alvazan.com/samplepage  Web.samplePage

I can go to xxxx.dev.alvazan.com/test just fine UNTIL I add a reference to samplePage.html like so....

<a href="@{Web.samplePage()}">TRY ME</a>

and of course that is because the method is really Web.samplePage(String company) so that a user can go directly to that web page...but I try changing to one of theses and it doesn't work either...

<a href="@{Web.samplePage('${company}')}">TRY ME</a> 
<a href="@{Web.samplePage(${company})}">TRY ME</a>

How does one make sure the Web.samplePage is correct in the href above in the html???

thanks, Dean

1条回答
做个烂人
2楼-- · 2019-07-07 09:09

Because you have already specified the @ symbol, you don't need to then use the $ symbol, as the groovy compiler is at that point expecting code. So, assuming company has been passed into the view from the controller, you should be able to do...

<a href="@{Web.samplePage(company)}">TRY ME</a>
查看更多
登录 后发表回答