title: Spring Security - Localized Messages
body: <p>I'm trying to localize the messages thrown by Spring Security. I'm using Spring 4.3.1 and Spring Security 4.1.1.
  The localization of other values using messages.properties is working fine, only the Spring Security messages do not work properly. I get all the time the same message regardless of the language (in my case I get all the time the german message ("Benutzername oder Passwort falsch")). Is there something that I forgot to configure?</p>
  
  <p><strong>snippet from mvc-dispatcher-servlet.xml</strong>  </p>
  
  <pre><code>&lt;bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"&gt;
          &lt;property name="basenames" value="messages"/&gt;
  &lt;/bean&gt;
  &lt;bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"/&gt;
  &lt;mvc:interceptors&gt;
      &lt;bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"&gt;
          &lt;property name="paramName" value="language"/&gt;
      &lt;/bean&gt;
  &lt;/mvc:interceptors&gt;
  </code></pre>
  
  <p><strong>loadByUsername method (if needed)</strong></p>
  
  <pre><code>public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DisabledException {
      Member member = memberDao.getMember(username);
      if (member == null) {
          throw new UsernameNotFoundException("user not found...");
      } ...
  </code></pre>
  
  <p><strong>web.xml</strong></p>
  
  <pre><code>&lt;!--DispatcherServlet--&gt;
  &lt;servlet&gt;
      &lt;servlet-name&gt;mvc-dispatcher&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;mvc-dispatcher&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;!--ContextLoaderListener--&gt;
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;
          /WEB-INF/mvc-dispatcher-servlet.xml,
          /WEB-INF/spring-security.xml
      &lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;filter&gt;
      &lt;filter-name&gt;requestContextFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.filter.RequestContextFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;requestContextFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  
  &lt;!-- Spring Security Chain Filter --&gt;
  &lt;filter&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p><strong>messages_de.properties</strong></p>
  
  <pre><code>AbstractUserDetailsAuthenticationProvider.badCredentials=Benutzername oder Passwort falsch
  field.username=Benutzername
  </code></pre>
  
  <p><strong>messages_en.properties</strong>  </p>
  
  <pre><code>AbstractUserDetailsAuthenticationProvider.badCredentials=Wrong username or password
  field.username=Username
  </code></pre>