shiro中登录的时候url地址栏带jsessionid的两种方式
1.web.xml
web.xml必须为3.0版本
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <!-- 在web.xml中加入如下配置 --> <session-config> <tracking-mode>COOKIE</tracking-mode> </session-config> </web-app>
2.使用Spring的会话管理
shiro版本在1.3.2版本以上已修复该问题,只需要在shiro配置文件添加以下配置即可:
<!--创建SecurityManager对象 --> <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"> <!--将realm设置到securityManager主体中 --> <property name="realm" ref="realm" /> <!-- 定义要使用的session管理器 --> <property name="sessionManager" ref="sessionManager"/> </bean> <bean id="sessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager"> <!--避免url中出现jsessionid 2017-11-04修改--> <property name="sessionIdUrlRewritingEnabled" value="false"/> </bean>
下一篇:
jar包双击打不开或者闪退的解决办法