4

我已经覆盖了该方法public Result onError(RequestHeader rh, Throwable t),但是这个类RequestHeader似乎没有保存请求正文 - API

有人知道如何在这里获取请求正文吗?

4

1 回答 1

4

简单的解决方案 - 我覆盖了我可以使用的public Action<?> onRequest(Request request, Method actionMethod)保存位置。RequestBodyonError

:)

private RequestBody lastBody;

@Override
public Action<?> onRequest(Request request, Method actionMethod) {
    lastBody = request.body();
    return super.onRequest(request, actionMethod);
}

@Override
public Result onError(RequestHeader rh, Throwable t) {  
    //here i can get the body
    System.out.println(lastBody);

    return play.mvc.Results.internalServerError(errorPage.render());
}
于 2013-02-25T15:39:43.283 回答