【问题标题】:onRequest() is not working in Play! framework 2.5.xonRequest() 在 Play 中不起作用!框架 2.5.x
【发布时间】:2017-01-31 10:47:09
【问题描述】:

我想在将请求分派到操作之前执行业务逻辑。

这是我的代码:

public class Global extends GlobalSettings {

    public Action onRequest(Http.Request request, Method actionMethod){
        System.out.println("before each request..." + request.toString());
        return super.onRequest(request, actionMethod);
    }

}

但它不起作用。

【问题讨论】:

    标签: java playframework playframework-2.5


    【解决方案1】:

    作为远离全局状态的一部分,Play 2.5 已弃用 Global

    改用过滤器。您可以在documentation 中找到详细的明细。

    【讨论】:

    • 当我从其他游戏中调用 API 时,JavaHttpFilters 不起作用!框架应用或 Android 应用
    • 听起来你还没有定义过滤器链。
    • 我是新手,所以我遇到了问题。如果我创建可以路由 API 请求的自定义路由会怎样
    • Stack Overflow 是针对特定问题的。如果您遇到一般问题,请前往支持小组groups.google.com/forum/#!forum/play-framework
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-08
    • 2014-11-13
    • 2023-03-18
    • 2018-04-05
    相关资源
    最近更新 更多