一、在 pom.xml 添加 Springsession
<!-Springsession-> <การพึ่งพา> <roupId> org.springframework.session </groupId> <ratifactid> Spring-Session-Data-Redis </artifactid> <version> 1.2.0.release
二、确保 ฤดูใบไม้ผลิ是 4.3.10 รีลีส版本以上
<Efferency> <roupID> org.springframework </groupId> <ratifactId> Spring-Context </artifactid> <version> 4.3.10.release </version>
三、 ApplicationContext.xml 文件中添加四个ถั่ว类
<bean id = "redishttpsessionConfiguration"> <property name = "MaxinactiveIntervalinseconds" value = "180"> </คุณสมบัติ> </epean> <bean id = "JedispoolConfig"> </epan> name = "พอร์ต" value = "6379"> </คุณสมบัติ> <property name = "poolconfig" ref = "jedispoolconfig"> </property> </epean> <bean id = "defaultCookieserializer"> <property name = "cookiename" value = "Springsession"> value = "3600"/> <property name = "usehttponlyCookie" value = "true"/> <property name = "domainName" value = ". qs.com"/> </ebean>
这样就可以实现เซสชัน享享, nginx 下的 tomcat 集群也是这样的
原理就是: 通过 Springsession 对 servlet 带的เซสชัน进行封装, 接管เซสชัน