Dreampie/Resty

Resty怎么获取Session?

jiangjunfeng98 opened this issue · 2 comments

调试的时候debugger里面可以this.getRequest().request.getSession().getAttributeNames()获取,
1

但是代码里this.getRequest()里面没有request,这个时候我该怎么获取Session呢?

image

resty提供了分布式的session,Subject对象来操作,如果要获取原生的request对象,使用 unwrap 方法

public <T> T unwrap(Class<T> clazz) {
    if (clazz == HttpServletRequest.class || clazz == ServletRequest.class) {
      return (T) request;
    }
    throw new IllegalArgumentException("underlying implementation is HttpServletRequest, not " + clazz.getName());
  }

谢谢,解决了