目录
1、spring-session
官方文档:https://docs.spring.io/spring-session/docs/1.3.0.RELEASE/reference/html5/
1.1 添加依赖
1.2 spring-mvc.xml配置文件
1.3 web.xml
这样就可以实现分布式Session了。
注意:
1)spring的这个配置文件一定要写在web.xml的<context-param>部分,写在其他地方不行。
2)filter的名字必须是springSessionRepositoryFilter
3)如果使用了shiro,web.xml中一定要把<context-param>放在最前面,然后写shiro的Filter配置,再写spring-session的Filter配置。后面就是其他的编码和servlet配置了。
2、tomcat配置session、共享
要求Tomcat7,tomcat8不支持
2.1 Tomcat配置
编辑${TOMCAT_HOME}/conf/context.xml,在context中加入
Tomcat安装lib目录添加以下jar包: