title: Thymeleaf: cannot handling input form Spring Boot
body: <p>I am new in web app development and I want to create a login page for my web app (using Spring boot + Thymeleaf), but I cannot display the <code>form.html</code> when I make a request for <code>/form</code>.</p>
  
  <p>This is my <code>Entity</code> class:</p>
  
  <pre><code> package com.example.springboot.model;
  
      public class ApplicationUser {
      private String username;
      private String password;
  
      public ApplicationUser(String username, String password) {
          this.username = username;
          this.password = password;
      }
  
      public ApplicationUser() { }
  
      public String getUsername() {
          return username;
      }
  
      public void setUsername(String username) {
          this.username = username;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  }
  </code></pre>
  
  <p>My <code>form.html</code> looks like this:</p>
  
  <pre><code> &lt;!DOCTYPE html&gt;
  &lt;html xmlns:th="http://www.thymeleaf.org"&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
      &lt;title&gt;Form Submission&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;User form&lt;/h1&gt;
      &lt;form action="#" th:action="@{/form}" th:object="${applicationuser}" method="post"&gt;
          &lt;p&gt;Username: &lt;input type="text" th:field="*{username}"/&gt;&lt;/p&gt;
          &lt;p&gt;Password: &lt;input type="text" th:field="*{password}"/&gt;&lt;/p&gt;
          &lt;p&gt;&lt;input type="submit" value="Send"/&gt;&lt;/p&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And the <code>result.html</code> is </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns:th="http://www.thymeleaf.org"&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
      &lt;title&gt;Result&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;Result&lt;/h1&gt;
      &lt;p th:text="'username: ' + ${applicationuser.username}"/&gt;
      &lt;p th:text="'password: ' + ${applicationuser.password}"/&gt;
      &lt;a href="/form"&gt;Submit another&lt;/a&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>But <code>applicationuser</code> from <code>th:object="${applicationuser}"</code> is highlighted in red ("cannot resolve "applicationuser"). Can this be a problem? How to resolve it?</p>
  
  <p>My <code>Controller</code> class is</p>
  
  <pre><code> @RestController
  public class Test {
  
      @RequestMapping(value = "/form",method = RequestMethod.GET)
      public String userForm(Model model){
          model.addAttribute("applicationuser",new ApplicationUser());
          return "form";
      }
  
      @RequestMapping(value = "/form",method = RequestMethod.POST)
      public String userSubmit(@ModelAttribute ApplicationUser user,Model model){
          model.addAttribute("applicationuser",user);
          String info = String.format("User Submission: username = %s, password = %s", user.getUsername(),user.getPassword());
          System.out.println(info);
          return "result";
      }
  }
  </code></pre>
  
  <p>I'm just trying to get input form and display them in console, but no way...
  When I make a request in my browser: <a href="http://localhost:8080/form" rel="nofollow noreferrer">http://localhost:8080/form</a> I obtain a white page with follow string "form", it doesn't display the textfields and button.
  I have in pom.xml the thymeleaf dependency:</p>
  
  <pre><code>&lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Does anyone known what is the problem with my code?</p>