IDEA JeeSite框架httpSession.invalidate()無效問題解決方案
想要實(shí)現(xiàn)一個(gè)功能:同一個(gè)用戶在兩個(gè)不同的瀏覽器中登錄,后面的踢掉之前的登錄。
本來的思路是在httpSession監(jiān)聽器中進(jìn)行判斷。但是在使用httpSession.invalidate();銷毀Session的時(shí)候,這一句話會(huì)拋出奇怪的異常,怎么都解決不了。
這個(gè)時(shí)候可以使用一個(gè)比較笨的但是有效的一個(gè)方法來替代:
httpSession.setMaxInactiveInterval(1);
在代碼中設(shè)置過期時(shí)間為1秒鐘
當(dāng)然這個(gè)方法只是耍小聰明,后來發(fā)現(xiàn),我遇到的問題,實(shí)際上是JeeSite 框架集成了Shiro 登陸框架,而這個(gè)框架,已經(jīng)默認(rèn)實(shí)現(xiàn)了之前描述的功能,在它自定義的登錄登出攔截器中。
<!-- 定義Shiro安全管理配置 --> <bean class='org.apache.shiro.web.mgt.DefaultWebSecurityManager'> <property name='realm' ref='systemAuthorizingRealm' /> <property name='sessionManager' ref='sessionManager' /> <property name='cacheManager' ref='shiroCacheManager' /> </bean> <!-- 自定義會(huì)話管理配置 --> <bean class='com.thinkgem.jeesite.common.security.shiro.session.SessionManager'> <property name='sessionDAO' ref='sessionDAO'/> <!-- 會(huì)話超時(shí)時(shí)間,單位:毫秒 --> <property name='globalSessionTimeout' value='${session.sessionTimeout}'/> <!-- 定時(shí)清理失效會(huì)話, 清理用戶直接關(guān)閉瀏覽器造成的孤立會(huì)話 --> <property name='sessionValidationInterval' value='${session.sessionTimeoutClean}'/> <property name='sessionValidationSchedulerEnabled' value='true'/> <property name='sessionIdCookie' ref='sessionIdCookie'/> <property name='sessionIdCookieEnabled' value='true'/> </bean>
只需要修改屬性文件jeesite.properties 中的屬性即可
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 讓chatgpt將html中的圖片轉(zhuǎn)為base64方法示例2. PHP設(shè)計(jì)模式中觀察者模式講解3. asp(vbs)Rs.Open和Conn.Execute的詳解和區(qū)別及&H0001的說明4. ASP基礎(chǔ)知識(shí)Command對象講解5. asp畫中畫廣告插入在每篇文章中的實(shí)現(xiàn)方法6. JSP中param動(dòng)作的實(shí)例詳解7. ASP新手必備的基礎(chǔ)知識(shí)8. JSP的setProperty的使用方法9. chat.asp聊天程序的編寫方法10. PHP實(shí)現(xiàn)圖片旋轉(zhuǎn)的方法詳解
