作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我问这个问题是因为它与 another 松散相关我的帖子之一。
是否可以在 Play Framework (2.0.4)中检索当前加载页面的 URL?例如,如果我想修改这个方法:
@Override
public Call afterAuth() {
*IF CURRENT URL = "localhost:9000/mobile"
return routes.Application.mobile_index();
*ELSE*
return something.else;
}
最佳答案
您可以使用 Request获取主机 url 的实例:
public static Result someControllerMethod() {
String uri = request().uri();
if (routes.Application.mobile_index().url().equals(uri)) {
return ok(views.html.mobile_main.render());
} else {
return ok(views.html.index.render());
}
}
其实我不知道你的应用架构细节,但是你可以通过Http.Context到您的登录处理程序。
更新我不熟悉 play-authenticate 模块。我只是查看了这个来源,不知道如何在 Resolver 方法中访问 Http.Context。我只找到了 this question其中提出了一些解决方法,但它看起来不像是一个优雅的解决方案。
关于playframework - 获取当前加载页面的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16263631/
我在 StackOverflow 和其他地方看到了很多与此类似的问题,但没有一个直接解决我的问题。我正在 THREE.js 中使用凸包生成器生成 n 边多面体。我想将方形纹理映射到每个多面体的每个面上
我是一名优秀的程序员,十分优秀!