adi*_*dis 6 playframework playframework-2.0 playframework-2.1
我正在为Play Subproject功能进行更多扩展测试,如下所述:http://www.playframework.com/documentation/2.0/SBTSubProjects.但是我收到了错误:
Assets is already defined as object Assets
Run Code Online (Sandbox Code Playgroud)
在github上托管的示例应用程序:https://github.com/adis-me/PlayStrap
我已经为我的子项目定义了一个Asset控制器,如下所述:资产控制器描述,即使是主项目,但错误仍然会弹出.我的项目有什么问题?
调节器
package com.company.playstrap.controllers;
import controllers.AssetsBuilder;
public class Assets {
public static controllers.AssetsBuilder delegate = new AssetsBuilder();
}
Run Code Online (Sandbox Code Playgroud)
路由文件
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Home page
GET / com.company.playstrap.controllers.Application.index()
# Include sub projects
-> /common common.Routes
-> /admin admin.Routes
-> /website website.Routes
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file com.company.playstrap.controllers.Assets.delegates.at(path="/public", file)
Run Code Online (Sandbox Code Playgroud)
这是一个众所周知的错误:https://groups.google.com/forum/#! msg/play- framework/2Zk5wjAlIng/Jcec1lt7AzQJ
我自己的管理模块的解决方法:
package controllers.admin;
import controllers.AssetsBuilder;
import play.api.mvc.AnyContent;
import play.api.mvc.Action;
import play.mvc.*;
public class Application extends Controller {
private static AssetsBuilder delegate = new AssetsBuilder();
public static Action<AnyContent> asset(String path, String file) {
return delegate.at(path, file);
}
}
//routes file
GET /assets/*file controllers.admin.Application.asset(path="/public", file)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5328 次 |
| 最近记录: |