title: How to pass values between pages using thymeleaf in a spring MVC web application
body: <p>I have a string variable that I create in a controller class and I want to print it in a jsp page using this</p>
  
  <pre><code>${time}
  </code></pre>
  
  <p>My code works if I don't use a thymeleaf view resolver, but if I do use one it doesn't work.</p>
  
  <p>Here is my controller class</p>
  
  <pre><code>@Controller
  public class HomeController {
  
  @RequestMapping(value = "/", method = RequestMethod.GET)
  public String home(Locale locale, Model model) {
  
       String thetime = "the time";
       model.addAttribute("time", thetime );
  
      return "home.jsp";
  }
  </code></pre>
  
  <p>And my .jsp page</p>
  
  <pre><code> &lt;html&gt;
     &lt;head&gt;
       &lt;title&gt;Home&lt;/title&gt;
     &lt;/head&gt;
   &lt;body&gt;
   &lt;h1&gt;
     Hello world!  
   &lt;/h1&gt;
  
   &lt;P&gt;  The time on the server is ${time}. &lt;/P&gt;
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My thymeleaf resolver configuration:</p>
  
  <pre><code>@Bean 
   public ServletContextTemplateResolver templateResolver() {
          ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();
          resolver.setPrefix("/WEB-INF/views/");
          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());
          engine.setMessageSource(messageSource());
  
          return engine;
      }
  
      @Bean 
      public ThymeleafViewResolver thymeleafViewResolver() {
          ThymeleafViewResolver resolver = new ThymeleafViewResolver();
          String[] vistas = {"*.html", "*.jsp"};
          resolver.setTemplateEngine(templateEngine());
          resolver.setOrder(1);
          resolver.setViewNames(vistas);
          resolver.setCache(false);
          return resolver;
      }
  
      @Bean
      public SpringResourceTemplateResolver thymeleafSpringResource() {
          SpringResourceTemplateResolver vista = new SpringResourceTemplateResolver();
          vista.setTemplateMode("HTML5");
          return vista;
      }
  </code></pre>
  
  <p>Is there a special notation to do this with thymeleaf?</p>