标签: playframework

播放框架下载文件

我是游戏框架的新手,我想通过以下方式下载文件:

  • 从数据库中获取文件路径。
  • 单击该路径应以 Web 形式打开一个文件。

是否可以在游戏框架中做?如果是的话,请给我一些想法。

谢谢

playframework playframework-1.x

0
推荐指数
1
解决办法
3629
查看次数

Playframework 2.x部署的推荐应用服务器是什么?

我计划用来jBoss部署,管理和监控playframework应用程序,但是从https://github.com/play2war/play2-war-plugin/wiki/ConfigurationLoggingJBoss7,我发现jBoss和playframework不能很好地结合在一起.

官方文档中,它只说Apache或Nginx可用于HTTP服务器,但没有提到应用程序服务器.有没有人对Playframework部署的可行应用服务器有什么想法?怎么样的Apache TomcatGlassFish的

java jboss scala playframework playframework-2.0

0
推荐指数
1
解决办法
1812
查看次数

当我的其他人应该阻止它时,为什么我会得到IndexOutOfBoundsException?

我正在进行某种测验,并有一个问题和答案列表,通过控制器转移到我的视图类.人们可以在一个页面上提问和回答问题,然后我的系统会"收集"这些问题以便从中进行测验.

如果您是第一个启动程序/测验的人,则问题列表为空.因此,我想检查一个带有if/else子句的空测验,if-case似乎工作正常,但是else-case抛出一个IndexOutOfBoundsException而我不明白为什么.我认为当问题列表为空时不会使用else-part,因此不应该抛出异常.应该....

查看课程:

@(questionList: List[Question], answerList: List[Answer], answerRadioForm: Form[Answer])

@if(questionList.length == 0){
    No questions yet!
}

else {
<!-- As only the highest ranked question gets put into the List, there is only one entry on first place -->
<b>@questionList.get(0).questionText</b>

    @for(question <- questionList)  {
        @question.questionText - @question.ownerID <br>
    }
} 
Run Code Online (Sandbox Code Playgroud)

错误:

[IndexOutOfBoundsException: Index: 0, Size: 0]
49          <b>"""),_display_(/*27.8*/questionList/*27.20*/.get(0).questionText),format.raw/*27.40*/("""</b>
Run Code Online (Sandbox Code Playgroud)

那么,我在这里错过了什么?

scala exception playframework

0
推荐指数
1
解决办法
173
查看次数

运行激活程序运行时找不到Play框架未找到值routeGenerator

我正在尝试设置播放框架,但是在运行时

activator run
Run Code Online (Sandbox Code Playgroud)

我收到此错误

/build.sbt:17: error: not found: value routesGenerator
routesGenerator := InjectedRoutesGenerator
^
[error] Type error in expression
Run Code Online (Sandbox Code Playgroud)

我一直在寻找解决方案,但是运气框架2.3.9是否存在任何不兼容问题?

我的环境是Java 1.7.0_21的ubuntu 12.0.4

谢谢。

java scala playframework playframework-2.3

0
推荐指数
1
解决办法
1952
查看次数

Play Framework 2.4(Java)没有运行所有单元测试

问题描述

我无法通过"激活测试"来运行我的所有测试.我有几个测试文件(目前有5个).我们打电话给他们:

dir1\subdir1\ClassOneTest.java
dir1\subdir2\ClassTwoTest.java
dir1\subdir2\ClassThreeTest.java
dir1\subdir2\ClassFourTest.java
dir1\subdir2\ClassFiveTest.java

当我运行"激活器测试"(和其他人......像~testQuick)时,只有四个运行(说"一"到"四")."五"不运行.我重构>将"Five"重命名为"Six",它仍然没有运行.

我首先怀疑我的测试代码,所以我删除了所有有意义的测试,并替换为简单assertTrue(false)assertTrue(true).我甚至删除了@RunWith或@FixMethodOrder等注释.尽管如此,问题仍然存在.

然后我尝试交换文件名.如果我用"Five"和"Four"切换名称,则新的"Four"运行,新的"Five"不运行.所以似乎问题与文件发现有关,而不是与其中的代码有关.注意:"Five"和"Four"位于同一目录中.

我也尝试将Play 2.1的建议应用于build.sbt (链接:Play Framework(2.1.3)不运行任何测试).所做的只是静音[info] Test ... started信息,但没有发现其他测试.

我已经没想完了.有没有人有我可以尝试的建议?如果您需要特定的代码示例/配置设置,请指定,我将尽力适应.

更多信息:
- 如果我更改了源代码,某些测试文件会被发现并运行.其他测试文件,没那么幸运.
- 使用IntelliJ Ultimate 15.0.2
- 测试目录结构遵循项目的结构
- 当前build.sbt具有:

javaOptions in Test += "-Dlogger.file=conf/logback.xml"
testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v")

playframework

0
推荐指数
1
解决办法
920
查看次数

我正在使用playframework 2.5.4 UNRESOLVED DEPENDENCIES错误创建简单的Web应用程序

根据迁移文档 和playframework 2.5.4的新应用文档,我有如下的项目结构.

plugins.sbt:

resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

 // Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.4")
Run Code Online (Sandbox Code Playgroud)

build.sbt:

name := """ProjectNameWebProxy"""

version := "1.0"

lazy val root = (project in file(".")).enablePlugins(PlayJava)
Run Code Online (Sandbox Code Playgroud)

但是没有找到依赖关系

 ::::::::::::::::::::::::::::::::::::::::::::::
 ::          UNRESOLVED DEPENDENCIES         ::
 ::::::::::::::::::::::::::::::::::::::::::::::
 :: com.typesafe.play#play-server_2.10;2.5.4: not found
 :: com.typesafe.play#play-java_2.10;2.5.4: not found
 :: com.typesafe.play#play-netty-server_2.10;2.5.4: not found
 :: com.typesafe.play#play-logback_2.10;2.5.4: not found
 :: com.typesafe.play#play-test_2.10;2.5.4: not found
 :: com.typesafe.play#play-omnidoc_2.10;2.5.4: not found
 ::::::::::::::::::::::::::::::::::::::::::::::
Run Code Online (Sandbox Code Playgroud)

请帮助我盯着Web代理上的演示项目.

playframework

0
推荐指数
1
解决办法
1668
查看次数

如何包装Scala进行理解以解决围绕Play的Form折叠的Future?

我有一个处理表单提交的操作.在验证表格之前,我需要解决两个期货.我以为我可以嵌套所有东西,意思是把它fold放在yield理解的块内.

例如:

  def handleFormSubmission = silhouette.SecuredAction.async { implicit request =>
    for {
      user <- userService.findOneByUserId(userId)
      avatar <- avatarService.findOneByUserId(userId)
    } yield {
      myForm.bindFromRequest.fold(
        formWithErrors => formWithErrorsBranch(formWithErrors, user, avatar),
        changeData => changeDataBranch(changeData, user, avatar))
    }
  }
Run Code Online (Sandbox Code Playgroud)

两个分支都返回Future[Result]并且签名folddef fold[R](hasErrors: Form[T] => R, success: T => R): R.据我了解,fold有两个功能与参数Form[T]T与两者的回报R.这意味着如果我在两个分支中返回Future[Result],fold也会返回Future[Result].然而,由于它被包裹内的理解来解决这两个期货useravatar,我就不需要具备Future[Result]而是Result.那是对的吗?如果是这样,我如何以非阻塞方式修复以下编译错误?

type mismatch;
 found   : …
Run Code Online (Sandbox Code Playgroud)

scala akka playframework playframework-2.2

0
推荐指数
1
解决办法
350
查看次数

如何在Scala Play框架中添加按钮处理程序?

我正在使用scala play framework + scala模板引擎进行前端.如何添加按钮处理程序?点击它时我需要调用一些函数.

<body>
    <p>Database interface<br />
        <textarea style="margin: 0px; height: 193px; width: 533px;" cols="40" name="comment" rows="3"></textarea>
    </p>
    <p><input type="submit" value="Select" /> <input type="submit" value="Insert" />  <input type="submit" value="Update" /></p>
</body>
Run Code Online (Sandbox Code Playgroud)

scala playframework twirl

0
推荐指数
1
解决办法
3461
查看次数

playframework scala Seq [Future [Model]]删除未来

我有以下问题,

我有一个Seq[Future[ProcessStepTemplatesModel]],我想删除内心的未来.

我想要得到的是一个Seq[ProcessStepTemplatesModel].

完整的代码看起来像这样

Future.sequence {
        processSteps.map { step => // This is a "for each" over a Seq[ProcessStepTemplatesModel]
            val prerequisiteFuture = processStepPrerequisitesDTO.getProcessStepPrerequisiteProcessTemplateIds(step.id.get)

            prerequisiteFuture.map(prereqTemplates => {

             processTemplateDTO.getProessTemplatesForStepPreqrequsites(prereqTemplates).map(pres => {
                 step.stepPrerequisites ++Some(pres)
                 step
                })

            })
        }
      }
Run Code Online (Sandbox Code Playgroud)

谢谢

更新:

def getEditProcessTemplateData(processTemplateId: Int) = Action.async {
    //Get all steps of this process templates
    val stepIds: Future[Seq[Int]] = processTemplateDTO.getProcessStepTemplateIds(processTemplateId)

    val process = for {
      allApprovedProcessTemplates <- processTemplateDTO.getApprovedProcessTemplates //Get all approved process templates
      processTemplate <- processTemplateDTO.getProcessTemplate(processTemplateId) // Get the Process …
Run Code Online (Sandbox Code Playgroud)

scala playframework playframework-2.0

0
推荐指数
1
解决办法
192
查看次数

Source [T,_]和Source [T,NotUsed]有什么区别?

我有一个构建在Play / Lagom堆栈之上的应用程序。我需要调用一项服务,该服务需要Source[T, NotUsed]将文件流式传输到该服务。这是服务的接口:

def foo(fooId: UUID): ServiceCall[Source[ByteString, NotUsed], Source[String, NotUsed]]
Run Code Online (Sandbox Code Playgroud)

因此,我通过Accumulator.source以下方式从Play文档中使用:

  private def doSomething(fooId: UUID): BodyParser[Future[Seq[String]]] = BodyParser { _ =>
    Accumulator.source[ByteString]
      .mapFuture { source: Source[ByteString, NotUsed] =>
        externalService
          .foo(fooId)
          .invoke(source)
          .map { x =>
            Right(x.runWith(Sink.seq[String]))
          }
      }
  }
Run Code Online (Sandbox Code Playgroud)

现在,在mapFuture调用中,source的类型为Source[ByteString, _],但是如果Source[ByteString, NotUsed]如上例所示,将其更改为以便调用服务,则在IDE中出现Source[ByteString, _]预期的错误 。难道不_意味着我可以将类型更改为想要的任何类型,包括NotUsed吗?另一方面,这两者在语义上是否应该等效吗?我发现,在某些以前的版本中,当实例化值无关紧要时,引入Akka团队akka.NotUsed来进行替换Unit,但这仍然无法为我提供解决问题的线索。

上面的代码段类似于Play文档中有关将身体指向其他位置的示例

scala covariance existential-type akka playframework

0
推荐指数
1
解决办法
77
查看次数