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