【问题标题】:Accessing HttpSession in PreProcessInterceptor在 PreProcessInterceptor 中访问 HttpSession
【发布时间】:2013-08-14 03:56:38
【问题描述】:

是否可以在PreProcessInterceptorpreProcess 方法中访问/创建HttpSession

(RestEasy 2.3.4)

【问题讨论】:

    标签: resteasy httpsession


    【解决方案1】:

    您可以通过使用@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...
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-04
      • 2018-03-21
      • 2012-04-04
      • 2016-07-30
      • 2014-03-20
      • 2013-12-07
      • 1970-01-01
      相关资源
      最近更新 更多