springboot 共享session

1、pom添加jar依赖

<dependency>  
        <groupId>org.springframework.boot</groupId>  
        <artifactId>spring-boot-starter-redis</artifactId>  
</dependency>  
<dependency>  
        <groupId>org.springframework.session</groupId>  
        <artifactId>spring-session-data-redis</artifactId>  
</dependency>  

2、开启session共享功能

@EnableRedisHttpSession 

3、配置添加

spring.redis.host=localhost  
spring.redis.port=6379 

4、spring boot + redis实现session共享完成

request.getSession().setAttribute("request Url", request.getRequestURL());

request.getSession().getAttribute("request Url");

 

posted @ 2019-01-08 14:48  故事里的牧羊人  阅读(446)  评论(0编辑  收藏  举报