vue+axios+springboot+redis 实现session 共享
来源:互联网 发布:java 面试项目 编辑:程序博客网 时间:2024/06/06 01:17
太坑了!!!!
终于弄好了,分享给大家
步骤一:
步骤四:
在axios加上:
或者用spring4.2版本的注解:
终于弄好了,分享给大家
步骤一:
首先我们添加@EnableRedisHttpSession来开启spring session支持,配置如下:
import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;@Configuration@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 86400 * 30)public class RedisSessionConfig {@Beanpublic JedisConnectionFactory connectionFactory() {return new JedisConnectionFactory();}}
步骤二:
在pom.xml文件中添加:
<dependency><groupId>org.springframework.session</groupId><artifactId>spring-session</artifactId></dependency><dependency><groupId>org.springframework.session</groupId><artifactId>spring-session-data-redis</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency>
步骤三:
在application.properties中配置redis服务器的位置,在这里,我们就用本机:
spring: session: store-type: REDIS redis: host: localhost port: 6379
步骤四:
在axios加上:
import axios from 'axios';axios.defaults.withCredentials=true;//让ajax携带cookieVue.prototype.$axios = axios;
然后在后端接口方法上添加:
res.header('Access-Control-Allow-Origin', '*');res.header('Access-Control-Allow-Credentials', 'true');res.header('Access-Control-Allow-Methods', req.header('Access-Control-Request-Method'));res.header('Access-Control-Allow-Headers', req.header('Access-Control-Request-Headers'));
或者用spring4.2版本的注解:
@CrossOrigin
阅读全文
0 0
- vue+axios+springboot+redis 实现session 共享
- springboot整合redis,实现session共享
- springboot(七)redis 实现session共享
- 使用springboot+redis实现session共享
- springboot + redis集群实现session共享
- vue axios springboot 跨域
- SpringBoot-Redis实现session共享(图片验证码验证)
- springboot利用springsession实现redis共享session,并且自定义sessionid
- SpringBoot+Redis+Nginx实现负载均衡以及Session缓存共享
- redis实现session共享
- redis实现session共享
- Redis实现Session共享
- redis实现session共享
- redis实现session共享
- [Session共享]Spring-Redis实现Session共享
- springboot整合redis使用nginx实现负载均衡实现session共享
- SpringBoot之——spring boot + redis 实现session共享随笔
- redis+tomcat7实现session共享
- 关于python构造函数
- c++ c 时间戳获取 秒级 微秒级 纳秒级别
- 彻底搞定NIO(一)
- fiddler,他和其他抓包软件有什么区别,如何使用fiddler进行抓包
- Tomcat
- vue+axios+springboot+redis 实现session 共享
- input回车事件
- 使用Travis进行持续集成
- 戴尔poweredge r730服务器配置以及安装系统
- 448. Find All Numbers Disappeared in an Array
- Java中的关键字和保留字
- Alias: Potteryable precursor polymer
- android 语音即时通讯之录音、播放实现
- xml基础