我使用Spring会话的1.0.1版本。我已经使用XML配置设置了我的应用程序。现在我需要根据某些属性将cookie名称从默认的“会话”更改为“会话”。例如,在myApp_SESSION中,将从属性文件中读取myApp。
我注意到,SessionRepositoryFilter只有一个构造函数,它使用默认值接受sessionRepository和带有CookieHttpSessionStrategy的httpSessionStrategy。
我当前的XML配置如下所示。
<bean id="mapSessionRepository" class="org.springframework.session.MapSessionRepository" />
<bean id="springSessionRepositoryFilter" class="org.springframework.session.web.http.SessionRepositoryFilter">
<constructor-arg ref="mapSessionRepository" />
</bean>是否可以通过向CookieHttpSessionStrategy bean注入一个springSessionRepositoryFilter来更改cookie名称?
发布于 2015-05-07 20:44:10
你是对的。可以将带有自定义cookie名称的CookieHttpSessionStrategy注入到SessionRepositoryFilter中。
<bean id="sessionRepositoryFilter"
class="org.springframework.session.web.http.SessionRepositoryFilter">
<constructor-arg ref="sessionRepository"/>
<property name="httpSessionStrategy">
<bean class="org.springframework.session.web.http.CookieHttpSessionStrategy">
<property name="cookieName" value="myCookieName" />
</bean>
</property>
</bean>https://stackoverflow.com/questions/29964921
复制相似问题