是否可以在HttpSession
的{{1}}方法中访问/创建preProcess
?
(RestEasy 2.3.4)
答案 0 :(得分:3)
您可以通过使用HttpSession
注释注入HttpServletRequest
来访问@Context
,然后从请求中获取会话,如下所示:
@Context
private HttpServletRequest servletRequest;
@Override
public ServerResponse preProcess(HttpRequest request, ResourceMethod method)
throws Failure, WebApplicationException
{
HttpSession session = servletRequest.getSession();
//Do something with the session here...
}