[英]Play2 Framework Template parameters
我正在尝试开发一个模板,该模板的内容位于页面的中间(链接main.scala.html)。
这是我的密码
mainPage的模板(名称:test.scala.html)
@(title: String)(content: Html)
<p> Some HTML Stuff </p>
@content
secon页面(名称:test2.scala.html)
@(test:String)
@test("test2"){
<p> Hello World </p>
}
控制器
public class Admin extends Controller {
public static Result test(){
return ok(test.render("test"));
}
public static Result test2(){
return ok(test2.render("test2"));
}
}
这样就行不通了。 可能有人可以帮助我
这必须是编译错误,因为您的模板需要两个参数。
//scala template
@(title: String)(content: Html)
<p> Some HTML Stuff </p>
@content
// java call
public static Result test(){
return ok(test.render("test"));
}
您必须将一些HTML传递给测试模板
你的java调用可能像
return ok(test.render("test",test2.render("test2")));
但是在您的情况下,您应该只调用test2模板,因为您的测试模板更像是包装器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.