0

我正在将我的应用程序从 play 2.0.4 迁移到 play 2.1.0。Play 2.1 无法识别视图中的 flash、会话或请求,导致编译错误

如何在 play-2.1.0 中表示来自 play-2.0.4 的以下代码

A、闪光

@if(flash.contains("success")) {
        <p class="success">@flash.get("success")</p>

        }

B.会话 -----

@if(nav == "signup" && session.get("sitetype")=="public")

C. 请求

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>

非常感谢您的帮助。

4

2 回答 2

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"

于 2014-01-25T07:44:16.707 回答
0

添加附件和导入模板有帮助

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._") )

于 2013-03-12T05:37:32.180 回答