[英]Play framework 2: Error when trying to start application in production mode
[英]Play framework 2 tag compilation error
我是Play框架2的新手,我正在嘗試實現Java類支持的簡單標簽。 但是我無法工作,因為遇到編譯錯誤
瀏覽器上的編譯錯誤非法開始的簡單表達式在\\ app \\ views \\ tags \\ security.scala.html中的第3行。
標記文件views / tags / security.scala.html
@(roles:String)(body:Html)
@import helpers.SecurityHelper._
@if(restricted (@session().get("roles"),@roles)==true){
@body
}
助手類代碼包的助手;
public class SecurityHelper {
public static boolean restricted(String userRoles, String ressourceRoles) {
String[] roles = userRoles.split("_");
boolean b = false;
for (int i = 0; i < roles.length; i++) {
if (roles[i].indexOf(ressourceRoles) != -1) {
b = true;
}
}
return b;
}
}
我要如何使用它:在另一個模板中,我將標簽稱為:
@security("job-view"){
Welcome
}
我不知道這個問題,有什么建議嗎? 謝謝
也許您需要編寫html文件的下第一行:
@(roles:String, body:Html)(implicit session: Session)
而不是if語句中的“ @session”,足夠“ session”
但我需要更多有關錯誤的信息
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.