我正在将我的应用从Play 2.0.4迁移到2.1.0。 Play 2.1无法识别视图中的flash,会话或请求,从而产生编译错误
如何在play-2.1.0
中表示play-2.0.4中的以下代码一个。闪光
@if(flash.contains("success")) {
<p class="success">@flash.get("success")</p>
}
B.session -----
@if(nav == "signup" && session.get("sitetype")=="public")
℃。请求
var chatSocket = new WS("@routes.Chat.chat(username).webSocketURL(request)")
错误日志
[error] /Users/abhijitbasu/SampleApps/smartex-app/app/views/chatRoom.scala.html:120: not found: value request
[error] var chatSocket = new WS("@routes.Chat.chat(username).webSocketURL(request)")
[error] ^
^
[error] /Users/abhijitbasu/SampleApps/smartex-app/app/views/login.scala.html:16: not found: value flash
[error] @if(flash.contains("success")) {
[error] ^
[error] /Users/abhijitbasu/SampleApps/smartex-app/app/views/main.scala.html:159: not found: value session
[error] @if(nav == "signup" && session.get("sitetype")=="public") {
[error] ^
[error] /Users/abhijitbasu/SampleApps/smartex-app/app/views/mediainsight.scala.html:109: not found: value session
[error] ajaxpage(rootdomain+'@routes.Chat.chatRoom(session.get("firstname") + ' ' + session.get("lastname"))', 'contentarea')
[error] ^
[error] /Users/abhijitbasu/SampleApps/smartex-app/app/views/signup/form.scala.html:39: not found: value flash
[error] <p class="error">@flash.get("error")</p>
非常感谢帮助。
答案 0 :(得分:0)
添加appdendency和导入模板帮助
val appDependencies = Seq( javaCore,“org.apache.commons”%“commons-email”%“1.3.1”
)
val main = play.Project(appName,appVersion,appDependencies) .settings( templatesImport ++ = Seq(“play.mvc.Http.Context.Implicit._”) )
答案 1 :(得分:0)
派对有点晚了,但我有C节的解决方案。
在chatRoom.scala.html的顶部添加@(username: String)(implicit request: play.mvc.Http.Request)
这会带来错误,因为需要传递请求。您可能正在调用与ok(chat.render(username));
类似的代码,将其更改为ok(chat.render(username, request()))
;
在plugin.sbt中,添加以下行:javacOptions += "-Xlint:deprecation"