As long as the goal-specific and not half-hearted, perseverance and not halfway, we will be able to achieve our beautiful ideals.
Use Thymeleaf to bind a form to the object specified by Th:object.
<HTMLxmlns= "HTTP://WWW.W3.ORG/1999/XHMTL"xmlns:th= "http://www.thymeleaf.org"><Head><title>Register</title></Head><Body> <formMethod= "POST"Th:object= "${user}"> <Divclass= "Errors"th:if= "${#fields. HasErrors (' * ')}"> <ul> <LiTh:each= "ERR: ${#fields. Erros (' * ')}"Th:text= "${err}" >Input is incorrect</Li> </ul> </Div> <labelTh:class= "${#fields. HasErrors (' FirstName ')}? ' Error ' ">First Name</label> <inputtype= "text"Th:field= "*{firstname}"Th:class= "${#fields. HasErrors (' FirstName ')}? ' Error ' " /> <labelTh:class= "${#fields. HasErrors (' LastName ')}? ' Error ' ">Last Name</label> <inputtype= "text"Th:field= "*{lastname}"Th:class= "${#fields. HasErrors (' LastName ')}? ' Error ' " /> </form></Body></HTML>
<th:field> Specifies the properties of the bound object.
Spring_ implementing form Binding with Thymeleaf