spring mvc - Bind Duration object with form fields -


i have class field of type duration:

class myentity{  private duration duration; //getters, setters } 

now in thymeleaf template want have form hours, minutes , seconds:

<form method="post" th:action="@{/add}" th:object="${entity}">      <input type="number" th:field="???" min="0" />      <input type="number" th:field="???" min="0" max="59" />      <input type="number" th:field="???" min="0" max="59" /> </form> 

in controller have like:

@postmapping("/save") public string savetime(@modelattribute myentity entity) {     timerepo.save(timedata);     return "redirect:/"; } 

is possible thymeleaf bind model has more strings , numbers object types or have create dto , care myself wrapping/unwrapping data?

try using converter, link may if notion new you:

spring mvc - binding java backing objects custom converters


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -