spring-session实例

1.相关配置说明

<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
</bean>
 
<bean id="jedisConnectionFactory"
    class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
    <!-- IP -->
    <property name="hostName" value="10.0.21.241" />
    <!-- 端口 -->
    <property name="port" value="6379" />
     <!-- 密码,redis版本使用3.0.5默认为空,该值的位置:redis.conf里面的requirepass foobared项,默认是注释掉的-->
    <property name="password" value="" />
    <property name="timeout" value="10000" />
    <property name="poolConfig" ref="jedisPoolConfig" />
    <property name="usePool" value="true" />
</bean>
 
<bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
    <property name="connectionFactory" ref="jedisConnectionFactory" />
</bean>


2.web.xml文件配置

<!-- 配置spring-session拦截器 -->
<filter>
    <filter-name>springSessionRepositoryFilter</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
    <filter-name>springSessionRepositoryFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>


3.测试过程中碰到的问题

springSessionRepositoryFilter错误。解决:spring配置文件中加上扫描包的标签注解解决。<context:component-scan base-package="com.ss" />


4.简单的实例下载(后面有时间会再发个详细的例子)

http://download.youkuaiyun.com/detail/y_y_y_k_k_k_k/9195301

myeclipse项目,直接导入运行后,访问:http://127.0.0.1:8080/springsession/servlet/TestServlet?uid=1

然后观察查询redis验证

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值