小编ela*_*las的帖子

Spring security + LocaleResolver

我需要在成功验证后更改区域设置.

LocaleResolver中:

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

   <bean id="localeResolver"
     class="web.MyLocaleResolver">
   </bean>
Run Code Online (Sandbox Code Playgroud)
   public class MyLocaleResolver extends AbstractLocaleResolver {

   private Locale default = Locale.ENGLISH;

       @Override
       public Locale resolveLocale(HttpServletRequest hsr) {
           return this.default;
       }

       @Override
       public void setLocale(HttpServletRequest hsr, HttpServletResponse hsr1,         Locale default) {
           this.default = default;
       }

   }
Run Code Online (Sandbox Code Playgroud)

安全:

     <form-login login-page="/login" 
          authentication-success-handler- ref="MySuccessAuthHandler"/>
     <beans:bean id="MySuccessAuthHandler" class="web.MySuccessfulAuthenticationHandler">
         <beans:property name="defaultTargetUrl" value="/index.htm"></beans:property>
     </beans:bean>
Run Code Online (Sandbox Code Playgroud)
public class MySuccessfulAuthenticationHandler extends  SavedRequestAwareAuthenticationSuccessHandler  {
  @Override
  public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws ServletException, IOException { …
Run Code Online (Sandbox Code Playgroud)

java locale spring-mvc spring-security

3
推荐指数
1
解决办法
4557
查看次数

标签 统计

java ×1

locale ×1

spring-mvc ×1

spring-security ×1