访问PreProcessInterceptor中的HttpSession



是否可以在PreProcessInterceptorpreProcess方法中访问/创建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...
}

相关内容

  • 没有找到相关文章

最新更新