Spring整合Shiro出现There is no session with id [XXX] with root cause问题的解决方案

最近使用spring + shiro整合的时候出现一个非常头疼的问题,就是会经常出现There is no session with id [XXX]的问题,而且非常难调试出问题的所在,源码也看了关于shiro的部分,但是原因还是找不到。废话不多说,直接上配置文件shiro.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:cache="http://www.springframework.org/schema/cache"
	xmlns:p="http://www.springframework.org/schema/p" xmlns:websocket="http://www.springframework.org/schema/websocket"
	xmlns:task="http://www.springframework.org/schema/task"
	xsi:schemaLocation="
	http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-4.2.xsd
	http://www.springframework.org/schema/cache
	http://www.springframework.org/schema/cache/spring-cache-4.2.xsd
	http://www.springframework.org/schema/task
	http://www.springframework.org/schema/task/spring-task-4.2.xsd">

	<bean id="shiroSessionListener" class="com.vkl.mtjg.setting.shiro.ShiroSessionListener"></bean>
 	<!-- 会话DAO,sessionManager里面的session需要保存在会话Dao里,没有会话Dao,session是瞬时的,没法从  
     sessionManager里面拿到session --> 
	<bean id="sessionDAO" class="org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO">
		<property name="activeSessionsCacheName" value="shiro-activeSessionCache"/>
	</bean>
	<!-- 会话管理器 --> 
	<bean id="sessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
		<!-- Shiro去掉URL中的JSESSIONID --> 
		<property name="sessionIdUrlRewritingEnabled" value="false" />
		<property name="globalSessionTimeout" value="1800000"/>
		<property name="sessionDAO" ref="sessionDAO"></property>
		<property name="deleteInvalidSessions" value="true"/>
		<property name="sessionIdCookieEnabled" value="true"/>    
        <property name="sessionIdCookie" ref="sessionIdCookie"/>
      
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 10
    评论
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值