【原】保存一下之前spring-session的redis单点登录配置文件【跨域】
2017-02-21 21:01
363 查看
由于先前在调试项目的时候需要做单点,但是项目是基于spring-session老版本做的单点登录,没有实现跨域登录,因为只是针对相同域名下的用户缓存进行存储而已,例如 http://127.0.0.1/wap 和 http://127.0.0.1/wap2 ,这样的话只要在 第一个域名登录后再去第二2个域名进行用户登录,则无需重复登录,但是如果是 http://127.0.0.1/wap 和 http://192.168.1/wap2 这样就没办法找到session。
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:c="http://www.springframework.org/schema/c" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd "> <bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="maxTotal" value="${redis.maxTotal}" /> <property name="maxIdle" value="${redis.maxIdle}" /> <property name="maxWaitMillis" value="${redis.maxWaitMillis}" /> <property name="testOnBorrow" value="${redis.testOnBorrow}" /> </bean> <bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"> <property name="hostName" value="${redis.host}" /> <property name="port" value="${redis.port}" /> <property name="password" value="${redis.auth}" /> <property name="poolConfig" ref="poolConfig" /> </bean> <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"> <property name="connectionFactory" ref="connectionFactory" /> <!-- 如果不配置Serializer,那么存储的时候智能使用String,如果用对象类型存储,那么会提示错误对象 can't cast to String!!! --> <property name="keySerializer"> <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" /> </property> <property name="valueSerializer"> <bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" /> </property> </bean> <bean id="redisTemplateC" class="org.springframework.data.redis.core.RedisTemplate"> <property name="connectionFactory" ref="connectionFactory" /> <property name="keySerializer"> <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" /> </property> <property name="valueSerializer"> <!-- 设置值的序列化器,不然保存到Redis时会出现十六进制问题 --> <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" /> </property> </bean> <!-- 将session放入redis --> <bean id="redisHttpSessionConfiguration" class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration"> <property name="httpSessionStrategy" ref="cookieHttpSessionStrategy"/> </bean> 设置cookieName和path <bean id="defaultCookieSerializer" class="org.springframework.session.web.http.DefaultCookieSerializer"> <property name="cookieName" value="DTL_SESSION_ID" /> <property name="cookiePath" value="/" /> </bean> <bean id="cookieHttpSessionStrategy" class="org.springframework.session.web.http.CookieHttpSessionStrategy"> <property name="cookieSerializer" ref="defaultCookieSerializer" /> </bean> </beans>
相关文章推荐
- 使用Redis保存Spring session(基于XML配置文件)
- 使用Redis保存Spring session(基于XML配置文件)
- javaWeb项目SpringMVC3.2.1与Mybatis3.0.4整合实例(Mybaits-spring配置文件的几种方式)之一SqlSessionDaoSupport方式
- spring-session 使用redis来存储session配置文件
- 说一下Spring的applicationContext.xml的配置文件
- Eclipse保存Spring配置文件xml时显示Building Spring AOP reference model错误框的关闭方法
- Asp.net Core中使用Redis 来保存Session, 读取配置文件
- spring配置文件报java.lang.NoClassDefFoundError: org.hibernate.engine.SessionFactory
- php-fpm配置文件,指定session保存目录
- Spring-mybatis整合配置错误,显示不能创建spring配置文件中的sqlSessionFactory的Bean
- Spring配置文件和SpringMVC配置文件 web.xml配置文件 保存自用
- spring mvc4.2与spring-session整合后的跨域配置
- 使用Spring中Src下 -context.xml : 用资源文件夹保存数据库的链接信息 并在配置文件里读取
- 警惕手工加载spring配置文件导致数据库session无法释放
- OSworkflow,spring1.27,hibernate3集成-3.spring配置文件更改
- spring配置文件之灵活配置
- spring 配置文件
- Azureus研究-配置文件的参数读取和参数保存
- spring配置文件之灵活配置
- HOW TO:配置或数据文件的保存(改进)