title: How to pass only string in thymeleaf form?
body: <p>I have a little problem. When I have an object with some fields, it's easy to pass these fields through form:</p>
  
  <p>Controller:</p>
  
  <pre><code>@RequestMapping("/")
  public String hello(Model model) {
      model.addAttribute("test", Test);
      return "index";
  }
  </code></pre>
  
  <p>html:</p>
  
  <pre><code>&lt;form th:action="@{/process}"  method="post" th:object="${test}"&gt;
  &lt;input type="text" th:field="*{value}"/&gt;
  &lt;input type="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>But what if I don't want to have an object and pass only string? Something like that:</p>
  
  <p>Controller:</p>
  
  <pre><code>@RequestMapping("/")
  public String hello(Model model) {
      model.addAttribute("test", "test string");
      return "index";
  }
  </code></pre>
  
  <p>html:</p>
  
  <pre><code>&lt;form th:action="@{/process}"  method="post"&gt;
  &lt;input type="text" th:field="${test}"/&gt;
  &lt;input type="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>doesn't work.
  Thanks for help!</p>
  
  <p>For next question in comments:</p>
  
  <p>index.html:</p>
  
  <pre><code>&lt;form th:action="@{/process}"  method="post"&gt;
  &lt;textarea th:text="${sourceText}"/&gt;
  &lt;input type="submit" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>ggg.html:</p>
  
  <pre><code>&lt;textarea th:text="${sourceText}"/&gt;
  </code></pre>
  
  <p>controller:</p>
  
  <pre><code>@RequestMapping("/")
  public String hello(Model model) {
      model.addAttribute("sourceText", "asdas");
      return "index";
  }
  
  @RequestMapping("/process")
  public String process(Model model, @ModelAttribute(value = "sourceText") String sourceText) {
      return "ggg";
  }
  </code></pre>