NutzCN Logo
问答 nutzwk分布式,使用redis集群,默认是用httpsession吗?
发布于 3021天前 作者 qq_d6c9c504 2212 次浏览 复制 上一个帖子 下一个帖子
标签:

ShiroSessionProvider内的方法new ShiroHttpServletRequest(req, servletContext, true);后面一个true参数是控制创建的是httpsession,如果要换成shiroSession是不是要换成false?

	public HttpServletRequest filter(HttpServletRequest req, HttpServletResponse resp, ServletContext servletContext) {
		if ("OPTIONS".equalsIgnoreCase(req.getMethod())) {
			resp.addHeader("Access-Control-Allow-Origin", "*");
			resp.addHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Key");
		}
		if (req instanceof ShiroHttpServletRequest)
			return req;
		return new ShiroHttpServletRequest(req, servletContext, true);
	}
  public HttpSession getSession(boolean create) {

        HttpSession httpSession;

        if (isHttpSessions()) {
            httpSession = super.getSession(false);
            if (httpSession == null && create) {
                //Shiro 1.2: assert that creation is enabled (SHIRO-266):
                if (WebUtils._isSessionCreationEnabled(this)) {
                    httpSession = super.getSession(create);
                } else {
                    throw newNoSessionCreationException();
                }
            }
        } else {
            if (this.session == null) {

                boolean existing = getSubject().getSession(false) != null;

                Session shiroSession = getSubject().getSession(create);
                if (shiroSession != null) {
                    this.session = new ShiroHttpSession(shiroSession, this, this.servletContext);
                    if (!existing) {
                        setAttribute(REFERENCED_SESSION_IS_NEW, Boolean.TRUE);
                    }
                }
            }
            httpSession = this.session;
        }

        return httpSession;
    }
2 回复

你打印一下session类就知道了,没有用到容器session

来自炫酷的 NutzCN

@wendal 的确是 shirosession。

添加回复
请先登陆
回到顶部