我正在尝试使用Play 2.0 RC3.我已将框架解压缩到Program Files文件夹中,并重命名了文件夹'play20'.我将该文件夹输入到我的Windows路径中.
什么时候我运行Play,无论是play help
或者play new
,我总是得到Error: Could not find or load main class Files\play20\repository
我尝试进入文件夹本身,而不是从路径运行,我仍然得到相同的响应.
我知道在Stackoverflow中有一些类似的问题,但它们要么是.Net相关的,要么没有任何帮助我们的答案.
案例如下:我和一些朋友正在开展一个开源项目.在为有希望成功的项目奠定基础的同时,出现了一个问题:如何执行项目的代码约定?
原因在于,作为一个开源项目,如果人们开始按照自己的意愿重新格式化代码,补丁将因为格式化而变得混乱,因为格式化将隐藏补丁的真正"价值".所以我们想要一些强迫用户遵守特定格式的东西,如果他们不这样做就会破坏构建.
该项目使用Struts 2 + Spring + Hibernate,使用Maven 2(考虑转移到Maven 3).我们知道我们可以使用"CheckStyle"来测试Java文件,但这会留下一些问题,希望有人可以回答:
我们可以找到Jalopy for Java文件,但我们更喜欢免费工具(据我们所知,最新版本是付费的).我们仍然找不到任何SQL/XML.
更新:只是说清楚:我不是在询问PMD,Checkstyle或这些工具.我要求的工具是:
这是我的情况.我有一个使用guice模块的播放应用程序.为了使用guice模块:
play install guice
.这将安装在$PLAY_HOME/modules
我很好的.我不想以任何方式编辑模块文件.dependencies.yml
:- play -> guice 1.2
play dependencies
,这可以很好地恢复模块并创建一个modules/guice-1.2
引用guice模块的文件.问题是该文件的内容如下所示:/some-absolute-path/play-1.2.x/modules/guice-1.2
.
在本地开发工作时,这很好.但是,当我想转移到生产服务器时,使用不同的Play安装!(即使用不同的绝对路径)它显然会失败.
那么解决这个问题的最佳方法是什么?
现在我已经使用这样的方式声明application.conf
文件中的模块:module.guice=${play.path}/modules/guice-1.2
.不幸的是,${play.path}
魔法似乎不适用于那些生成的文件.
顺便说一句,我使用Play版本1.2.3!
我正在尝试围绕从会话中读取一些数据的方法构建一些测试.
我尝试扩展FakeRequest
和覆盖该session
值,但是我在编译时遇到错误,说session
必须是一个val
覆盖时,这将无效.
如何修改a FakeRequest()
以向会话添加值?
我正在使用Play 2.1.1并在application.conf
我添加以下自定义调度程序:
# Dispatcher for round-robin actors
play {
akka {
actor {
rr-dispatcher = {
type = BalancingDispatcher
executor = fork-join-executor
fork-join-executor {
parallelism-min = 2
parallelism-factor = 2
parallelism-max = 24
}
# messages per actor before jumping
throughput = 100
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试在演员身上使用它:
private val default = Akka.system.actorOf(Props[MessageRouterActor].withRouter(FromConfig()).withDispatcher("rr-dispatcher"), "msgRouter")
Run Code Online (Sandbox Code Playgroud)
但我得到这条消息说明找不到调度员:
[info] play - Starting application default Akka system.
[WARN] [04/20/2013 22:05:12.069] [application-akka.actor.default-dispatcher-5] [Dispatchers] Dispatcher [rr-dispatcher] not configured, using default-dispatcher
Run Code Online (Sandbox Code Playgroud)
据我所知,这似乎是添加它的正确方法.谁知道问题是什么?
我试图理解这个概念,但功能编程的力量在我看来还很弱,所以我无法立即掌握它.我希望做的是定义一个可重复使用的模板函数的一些参数,但在Html
身体以及.
例如,考虑模板中的以下可重用函数:
@myFunction(label: String, labelTarget: String, content: Html) = {
<label for="@labelTarget">@label</label>
<div>@content</div>
}
Run Code Online (Sandbox Code Playgroud)
我想用这个函数如下:
...
<h2>My function content below!</h2>
@myFunction("label", "target") {
<span>My additional content used by the function</span>
}
...
Run Code Online (Sandbox Code Playgroud)
我觉得这应该是可行的,但似乎无法弄明白.有帮助吗?
我正在尝试设置两个不同的静态资产路由,第二个失败.我错过了什么?
要复制此问题:
从scala样本开始的hello world.
在路由中添加一行,所以现在有两条静态路由:
GET /assets/*file controllers.Assets.at(path="/public", file)
GET /assets2/*file controllers.Assets.at(path="/public2", file)
Run Code Online (Sandbox Code Playgroud)注释掉main.scala.html中的Assets引用,因此它不会抱怨它们
把文件放在公共场所和公共场所2.
$ cat > public/foo.txt
hi
$ mkdir public2
$ cp public/foo.txt public2
Run Code Online (Sandbox Code Playgroud)验证公共目录是否有效.
$ telnet localhost 9000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /assets/foo.txt HTTP/1.0
HTTP/1.1 200 OK
Content-Length: 3
Content-Type: text/plain
Etag: 5246040afe91a4cc93bd838a4d5db3984b99470b
Cache-Control: no-cache
hi
Connection closed by foreign host.
Run Code Online (Sandbox Code Playgroud)验证第二个不起作用.
$ telnet localhost 9000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /assets2/foo.txt HTTP/1.0
HTTP/1.1 404 …
Run Code Online (Sandbox Code Playgroud)使用Play 2.0.1我定义了以下路由:
GET /demo/list controllers.Demos.listDemos(page: Int ?= 0, orderBy: Int ?= 1, nameFilter: String ?= "", versionFilter: Long ?= -1, tagFilter: List[String] ?= Nil)
Run Code Online (Sandbox Code Playgroud)
但我在编译时遇到这个错误:
No QueryString binder found for type List[String]. Try to implement an implicit QueryStringBindable for this type.
Run Code Online (Sandbox Code Playgroud)
我发现Play 2.1-RC(尚未正式发布)的代码可以解决这个问题:
/**
* QueryString binder for List
*/
implicit def bindableList[T: QueryStringBindable] = new QueryStringBindable[List[T]] {
def bind(key: String, params: Map[String, Seq[String]]) = Some(Right(bindList[T](key, params)))
def unbind(key: String, values: List[T]) = unbindList(key, values)
}
/**
* QueryString binder …
Run Code Online (Sandbox Code Playgroud) 我正在使用Play Framework 2.0(Scala)测试AngularJs.Play使用Closure来最小化Javascript文件.
我的文件如下:
// Define a Module 'todoList' for Angular that will load the views. In this example the views are very simple, it's just to show
// the concept
angular.module('todoList', ['taskDoneFilter', 'todoServices']).
config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/all', {templateUrl: 'assets/angular/all.html', controller: TodoCtrl}).
when('/task/:id', {templateUrl: 'assets/angular/task.html', controller: TaskDetailCtrl}).
otherwise({redirectTo: '/all'});
}]);
// This filter allows us to convert strings. In this case, it adds an extra tick besides a task indicating if it's done or no
angular.module('taskDoneFilter', []).filter('checkmark', function() { …
Run Code Online (Sandbox Code Playgroud) javascript google-closure-compiler playframework-2.0 angularjs
我有一个输入字段,从前一个表单填充(所以输入在第二页上设置为禁用)然后我们收到null
值.这有效:
<input type="text" class="boxtpl" name="${field.name}" value="${user?.email}">
Run Code Online (Sandbox Code Playgroud)
但这不是:
<input type="text" class="boxtpl" name="${field.name}" value="${user?.email}" disabled="disabled">
Run Code Online (Sandbox Code Playgroud)
有没有理由为什么这似乎打破了框架?