Playframework 游戏2.0.4“抓住所有路线始终命中”
在我的routes文件的末尾,我放置了一个catch all路由来捕获以前未捕获的请求,并将其传递给我自己的路由器(用于进一步处理): 当然,在这条线之前还有很多其他路线。对我来说,最大的惊喜是,每次都会命中“一网打尽”,即使上一条路线也是命中的,所以如果我打开addressPlayframework 游戏2.0.4“抓住所有路线始终命中”,playframework,routes,playframework-2.0,Playframework,Routes,Playframework 2.0,在我的routes文件的末尾,我放置了一个catch all路由来捕获以前未捕获的请求,并将其传递给我自己的路由器(用于进一步处理): 当然,在这条线之前还有很多其他路线。对我来说,最大的惊喜是,每次都会命中“一网打尽”,即使上一条路线也是命中的,所以如果我打开addressdomain.tld/test它会在控制台中显示两个日志test action hit和自定义路由器点击。有一个简化的示例: public static Result test() { Logger.debug("T
domain.tld/test
它会在控制台中显示两个日志test action hit代码>和自定义路由器点击代码>。有一个简化的示例:
public static Result test() {
Logger.debug("Test action hit!");
return ok();
}
public static Result router(String nameUrl) {
Logger.debug("Custom router hit!");
return ok();
}
路线(按此顺序)
我想得到什么:
我想用我的路由器iedomain.tld/category\u 1/article\u title
获取文章的url,前面没有任何前缀,当然,如果我将catch all更改为稳定的内容,它将不再获得双击:
GET /news/*nameUrl controllers.Application.router(nameUrl: String)
domain.tld/news/category_1/article_title
然而,我真的想避免/news/
段。这可能吗?我重复了一遍,发现Chrome(谷歌Chrome的核心)也有同样的问题,但Firefox没有
我使用Global.java分析了请求
public class Global extends GlobalSettings {
@Override
public Action onRequest(Http.Request request, Method method) {
Logger.info("request-path: " + request.path());
return super.onRequest(request, method);
}
}
//output:
[info] application - request-path: /favicon.ico
对于每个GET/test请求,Chromium都会尝试加载favicon
因此,在conf/routes中包括以下内容:
GET /favicon.ico controllers.Assets.at(path="/public", file="favicon.ico")
我重复了一遍,Chrome(谷歌Chrome的核心)也有同样的问题,但Firefox没有
我使用Global.java分析了请求
public class Global extends GlobalSettings {
@Override
public Action onRequest(Http.Request request, Method method) {
Logger.info("request-path: " + request.path());
return super.onRequest(request, method);
}
}
//output:
[info] application - request-path: /favicon.ico
对于每个GET/test请求,Chromium都会尝试加载favicon
因此,在conf/routes中包括以下内容:
GET /favicon.ico controllers.Assets.at(path="/public", file="favicon.ico")
+1使用play new
创建新项目时,favicon.ico路由应与资产路由一起添加+1使用play new
创建新项目时,favicon.ico路由应与资产路由一起添加。