title: Set language springMVC/Thymeleaf
body: <p>I'm working on a webapp using Spring MVC and Thymeleaf with Java-configuration. In the template for the <code>html</code> page the language is set to be Swedish through this code:</p>
  
  <pre><code>&lt;html lang="sv"&gt;
  </code></pre>
  
  <p>And the encoding is set to UTF-8 through this meta tag:</p>
  
  <pre><code>&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  </code></pre>
  
  <p>But for some reason, that will not display the swedish letters.</p>
  
  <p>I tried changing the <code>&lt;html&gt;</code> tag to the XHTML version <code>xml:lang="en"</code> but it makes no difference.</p>
  
  <p>Since I'm still very new to Spring and Thymeleaf, I don't know where something might be wrong, or where the language/charset is supposed to be stated/set so I'm giving you the thymeleaf configuration code and the page controller:</p>
  
  <pre><code>@Configuration
  public class ThymeleafConfig {
  
      @Bean
      public ServletContextTemplateResolver templateResolver() {
          ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();
          resolver.setPrefix("/WEB-INF/pages/");
          resolver.setSuffix(".html");
          resolver.setTemplateMode("HTML5");
          resolver.setOrder(1);
                  resolver.setCacheable(false);
          return resolver;
      }
  
      @Bean
      public SpringTemplateEngine templateEngine() {
          SpringTemplateEngine engine = new SpringTemplateEngine();
          engine.setTemplateResolver(templateResolver());
          return engine;
      }
  
      @Bean
      public ThymeleafViewResolver thymeleafViewResolver() {
          ThymeleafViewResolver resolver = new ThymeleafViewResolver();
          resolver.setTemplateEngine(templateEngine());
          return resolver;
      }
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>@Controller
  public class IndexController {
  
      @RequestMapping(value = "/", method = RequestMethod.GET)
      public ModelAndView index() {
          ModelAndView model = new ModelAndView();
          model.setViewName("index");
          return model;
      }
  }
  </code></pre>