Field value from name in thymeleaf
<p>I would like to convert this code to template that I can include by passing a name of field like that:</p>

<pre><code>&lt;div th:object="${form}"&gt;
  &lt;div th:replace="'templates/fields' :: input_text (fieldName='user.userName')" /&gt;
&lt;/div&gt;

&lt;th:block th:fragment="input_text"&gt; 
    &lt;input class="form-control"
           type="text"
           th:field="*{fieldName}"/&gt;
&lt;/th:block&gt;
</code></pre>

<p>The code above does not work unless I change from
 <code>th:field="*{fieldName}"</code> to <code>th:field="*{__${fieldName}__}"</code></p>

<p>Is there any way to do that without usage of preprocessing?</p>

<p>I actually need something like Fields.getValue(String fieldName);</p>

<p>@Controller:</p>

<pre><code>@RequestMapping(value = "/test", method = RequestMethod.GET)
  public String test(@ModelAttribute("form") TestForm form) {
    return "test"
  }

@RequestMapping(value = "/test", method = RequestMethod.POST)
  public String test(@Valid @ModelAttribute("form") TestForm form, BindingResult bindingResult) {
    return "test_success"
  }
</code></pre>

<p>bean</p>

<pre><code>public class TestForm implements Serializable {

  private static final long serialVersionUID = 123L;

  private String something;

  private String somethingElse;

  // ...
}
</code></pre>