是否可以在PreProcessInterceptor
的preProcess
方法中访问/创建HttpSession
?
(RestEasy 2.3.4)
您可以通过使用@Context
注释注入HttpServletRequest
来访问HttpSession
,然后从请求中获取会话,如下所示:
@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...
}