title: Thymeleaf: th:value - if property exists
body: <p>I want to create a hidden input field:</p>
  
  <pre><code>&lt;input type="hidden" th:value="${map.version} name="version"/&gt;
  </code></pre>
  
  <p><strong>Problem:</strong><br>
  <code>version</code> maybe a <strong>non existing</strong> attribute yet (I am not talking about  null!).<br>
  Right now I am getting an Exception <code>Property or field 'version' cannot be found on object</code></p>
  
  <p><strong>What I need:</strong><br>
  If it does not exist, th:value statement maybe ignored or tag removed</p>
  
  <p><strong>CLARIFICATION:</strong><br>
  <code>map</code> comes from Spring Controller in a handler-method: </p>
  
  <pre><code>@PostMapping("/new")
  public String handleMapFormSubmit(
      @ModelAttribute("map") @Valid AddMapCommand command, BindingResult result ) {
  
      if ( result.hasErrors() ) {
          return "map-form";
      }
  
      // do some stuff
  
      return ".....";
  }
  </code></pre>
  
  <p>Problem is that <code>map</code> (AddMapCommmand) in this handler-method <strong>does not contain</strong> the <code>version</code> attribute. In another handler-method (UpdateMapCommand) it does. The whole point is to <strong>reuse</strong> the <code>map-form</code> thymeleaf template in both scenarios which are almost similar.</p>