1

HttpSession是否可以在 a 的preProcess方法中访问/创建PreProcessInterceptor

(RestEasy 2.3.4)

4

1 回答 1

3

您可以HttpSession通过注入HttpServletRequestusing@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...
}
于 2013-08-13T19:56:38.547 回答