我已经覆盖了方法public Result onError(RequestHeader rh, Throwable t)
,但此类RequestHeader
似乎没有保存请求正文 - API
有人知道如何获取请求正文吗?
答案 0 :(得分:4)
简单的解决方案 - 我覆盖了public Action<?> onRequest(Request request, Method actionMethod)
我保存RequestBody
的地方onError
。
:)
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());
}