2016-09-07 1 views
0

Я использую spring session HttpSession, как я могу изготовить ключ cookie, я пробовал это решение: Custom cookie name when using Spring Session. но это не работает, имя СЕССИЯ все еще.java Весенняя сессия Как настраивать ключ для печенья

мой конфигурации, как показано ниже:

<context:annotation-config/> 
<bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration"/> 
<context:property-placeholder location="classpath:/env/env_test.properties"/> 
<bean class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" 
    p:port="${spring.redis.port}" p:hostName="${spring.redis.host}"/> 
<bean id="mapSessionRepository" class="org.springframework.session.MapSessionRepository" /> 
<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="_session_id" /> 
    </bean> 
    </property> 
</bean> 

ответ

0

Вам просто нужно добавить ниже bean создать custom cookie.

<bean class ="org.springframework.session.web.http.DefaultCookieSerializer"> 
      <property name="cookieName" value="JSESIONID"></property>  
    </bean> 

JESSIONID - Custom Cookie Name 

    Please remove below configuration fr`enter code here`om xml file. 

    <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="_session_id" /> 
     </bean> 
     </property> 
    </bean> 
Смежные вопросы