Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala 如何在playframework模板中获取控制器?_Scala_Playframework 2.0_Template Engine_Playframework 2.2 - Fatal编程技术网

Scala 如何在playframework模板中获取控制器?

Scala 如何在playframework模板中获取控制器?,scala,playframework-2.0,template-engine,playframework-2.2,Scala,Playframework 2.0,Template Engine,Playframework 2.2,我使用了playframework2.2: 我的模板是: @(topiclink:String, head: String, rate: Int, topicid:Int, summary: String, pic_url:String) @if(topiclink=="Shoplist"){ <a class="list-group-item" href="@routes.ShoplistController.pagelist(topicid.toString())"> }else

我使用了playframework2.2:

我的模板是:

@(topiclink:String, head: String, rate: Int, topicid:Int, summary: String, pic_url:String)
@if(topiclink=="Shoplist"){
<a class="list-group-item" href="@routes.ShoplistController.pagelist(topicid.toString())">
}else {
 <a class="list-group-item" href="@routes.PageController.pagelist(topicid.toString())"> 

}</a>
然后可以直接@topiclink.pagelist(topicid.tostring())


我可以直接找到相应的控制器页面。

直接在控制器中传递可能是个坏主意——考虑控制器创建表示数据(PaulListar)的对象。 不管怎样,无论你“传入”,控制器的工作就是“传入”——记住所有这些都是参数。如果确实需要控制器,则在创建页面的控制器中使用this关键字:

views.html.index.myPage(this, otherParam, ...)
views.html.index.myPage(this, otherParam, ...)