title: Not able to bind values from Thymeleaf based UI form to a controller in Spring Boot
body: <p>My application is not able to bind a form value from an <code>Thymeleaf + HTML</code> based UI to a <code>Spring Boot</code> controller.</p>
  
  <p>I am getting that value as <code>null</code> when I do a System.out.println into the controller.</p>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html xmlns:th="http://www.thymeleaf.org"&gt;
      &lt;head&gt;
          &lt;title&gt;Getting Started: Serving Web Content&lt;/title&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;p&gt;Get your greeting &lt;a href="/greeting"&gt;here&lt;/a&gt;&lt;/p&gt;
          &lt;form action="/publishMessage" method="post"&gt;
              &lt;table&gt;
                  &lt;tr&gt;
                      &lt;th&gt;CHARGE&lt;/th&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;
                          &lt;textarea th:field="*{messageBody}" name="" cols="90" rows="40"&gt;
                          {
                          "firstname": "Jose",
                          "lastname": "Long"
                          }
                          &lt;/textarea&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;&lt;input type="submit" name="btnSubmit" value="Publish CHARGE message"&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>PublishMessageController.java</strong></p>
  
  <pre><code>@Controller
  public class PublishMessageController {    
      @PostMapping("/publishMessage")
      public String publishMessage(Message message, BindingResult bindingResult, Model model) {
          System.out.println("into the publishMessage method..........");
          String messageBody = message.getMessageBody();
          System.out.println("messageBody: " + messageBody);
          return "result";
      }
  }
  </code></pre>
  
  <p><strong>Message.java</strong></p>
  
  <pre><code>import lombok.*;
  
  @Data
  @Getter
  @Setter
  @NoArgsConstructor
  public class Message {
      private String messageBody;
  }
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>into the publishMessage method..........
  messageBody: null
  </code></pre>