【发布时间】:2013-08-14 03:56:38
【问题描述】:
是否可以在PreProcessInterceptor 的preProcess 方法中访问/创建HttpSession?
(RestEasy 2.3.4)
【问题讨论】:
标签: resteasy httpsession
是否可以在PreProcessInterceptor 的preProcess 方法中访问/创建HttpSession?
(RestEasy 2.3.4)
【问题讨论】:
标签: resteasy httpsession
您可以通过使用@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...
}
【讨论】: