title: Spring multi-language
body: <p>I'm new working with Spring MVC and I have some problems to add multi language to my application.</p>
  
  <p>I dont' use xml configuration. I have a @Configuration class </p>
  
  <pre><code>import org.springframework.context.MessageSource;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.web.servlet.HandlerInterceptor;
  import org.springframework.web.servlet.HandlerMapping;
  import org.springframework.web.servlet.LocaleResolver;
  import org.springframework.web.servlet.ViewResolver;
  import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
  import org.springframework.web.servlet.i18n.CookieLocaleResolver;
  import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
  import org.springframework.web.servlet.i18n.SessionLocaleResolver;
  import org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping;
  
  @Configuration
  @EnableWebMvc
  @ComponentScan(basePackages="com.springexamples.basic.controller")
  public class BasicServletConfig extends BaseConfig {
  
      @Bean
      ViewResolver viewResolver() {
          return getViewResolver("views/basic/", ".jsp");
      }
  
      @Bean
      MessageSource messageSource() {
          return getMessageSource("/messages/messages");
  }
  
  @Bean
  LocaleChangeInterceptor localeChangeInterceptor() {
      LocaleChangeInterceptor interceptor = new LocaleChangeInterceptor();
      interceptor.setParamName("lang");
      return interceptor;
  }
  
  @Bean
  LocaleResolver localeResolver() {
      return new SessionLocaleResolver();
  }
  
  @Bean
  HandlerMapping handlerMapping() {
      SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
      mapping.setInterceptors(new HandlerInterceptor[] { localeChangeInterceptor() });
      return mapping;
  }
  }
  </code></pre>
  
  <p>When I test de application always I see the default language (spanish). I send the request with the parameter 'lang=en' or 'lang=EN' but I still see it in default language.</p>
  
  <p>¿Anyone knows the solution?.</p>
  
  <p>Thanks,</p>