2015-09-14 4 views
0

Я использую весеннюю безопасность и i18n. Мое приложение имеет 2 языка: Fr и En, Fr - по умолчанию. Однако, когда я вошел в систему, используя английский язык, а затем выйду из системы, я буду перенаправлен на домашнюю страницу. Я попытался изменить URL-адрес выхода, включая часть языка, например: "/login/login.mvc?logout=True?language=i18n_get_lang()" , но не удался. Любая идея, как решить эту проблему, была бы более чем приятной. PS, перенаправление входа работает правильно.Перенаправление после выхода на другой язык

Ниже мой springSecurity.xml

<beans:beans xmlns="http://www.springframework.org/schema/security" 
    xmlns:beans="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
    http://www.springframework.org/schema/security 
    http://www.springframework.org/schema/security/spring-security-4.0.xsd"> 



    <http auto-config="true" use-expressions="true"> 
     <intercept-url pattern="/login/login.mvc" access="isAnonymous()" /> 
     <!-- <intercept-url pattern="/admin**" access="ROLE_USER" /> --> 
     <form-login 
      login-processing-url="/login/login.mvc" 
      login-page="/login/login.mvc" 
      default-target-url="/login/accueil.mvc" 
      authentication-failure-url="/login/login.mvc?Error=True" 
      username-parameter="j_username" 
      password-parameter="j_password" /> 
     <logout logout-success-url="/login/login.mvc?logout=True?language=localeChangeInterceptor" 
       logout-url="/login/j_spring_security_logout"/> 
     <!-- unable csrf protection --> 
     <csrf disabled="true"/> 
    </http> 

    <authentication-manager> 
     <authentication-provider> 
      <user-service> 
      <user name="user" password="1234" authorities="ROLE_USER" /> 
      </user-service> 
     </authentication-provider> 
    </authentication-manager> 

</beans:beans> 

Мой MVC-servlet.xml

<?xml version="1.0" encoding="UTF-8" ?> 

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context-3.1.xsd 
     http://www.springframework.org/schema/mvc 
     http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd 
     http://www.springframework.org/schema/tx 
     http://www.springframework.org/schema/tx/spring-tx.xsd"> 

    <bean id="viewResolver" 
     class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
     <property name="prefix" value="/WEB-INF/pages/" /> 
     <property name="suffix" value=".jsp" /> 
    </bean> 

    <mvc:resources mapping="/css/**" location="/css/" /> 
    <mvc:resources mapping="/images/**" location="/images/" /> 
    <mvc:resources mapping="/js/**" location="/js/" /> 

    <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> 
     <property name="basename" value="classpath:i18n/Message"/> 
     <property name="defaultEncoding" value="UTF-8"/> 
    </bean> 

    <bean id="localeResolver" 
     class="org.springframework.web.servlet.i18n.SessionLocaleResolver"> 
     <property name="defaultLocale" value="fr" /> 
    </bean> 

    <bean id="localeChangeInterceptor" 
     class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"> 
     <property name="paramName" value="language" /> 
    </bean> 

    <mvc:interceptors> 
<!-- Changes the locale when a 'lang' request parameter is sent; e.g. /?lang=de --> 
    <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"> 
     <property name="paramName" value="language"/> 
    </bean> 
</mvc:interceptors> 

    <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping" > 
     <property name="interceptors"> 
      <list> 
      <ref bean="localeChangeInterceptor" /> 
      </list> 
     </property> 
    </bean> 


</beans> 

ответ

0

Я нашел решение: изменить SessionLocaleResolver к CookieLocaleResolver в MVC-servlet.xml.

Смежные вопросы