43- (Very Important)Thymeleaf Attributes and their roles or working
Image 1 - For Better understanding of th:each and model.addAttribute()
Lets understand with examples
1- model.addAttribute()
This means the value of studentService.getAllStudents() is given to "students"
2- th:each
This expression is used for iterating or creating a loop for students
3- th:text
Generating an input text for String firstName.
4- th:href
Context path for link basically anchor tag.
5- [ th:action ] & [ th:object ] & [ method ]
th:action
In simple terms where the data will be posted to /students .
OR
Used to provide the form action URL.
OR
Is an expression which in this case will direct the form to POST to the /students endpoint.
th:object
Object(in this case student) that needs to be stored in the database.
method="POST"
To perform POST operation to the form.
6- th:field
Matching the String firstName to the value of form.
Comments
Post a Comment