I am learning Spring MVC and I am unable to understand the difference between two examples.
1st example uses html form(helloWorld-form.jsp, helloWorld.jsp) while the 2nd example uses spring form(student-form.jsp, student-confirmation.jsp).
The corresponding HelloWorldController has two methods namely showForm and processFormVersion3 while the StudentController has methods showForm and processForm.
My questions are:
1. What is the advantage of using spring form over html form?
2. Why in the HelloWorldController the model's setAttribute is called in the processFormVersion3 method while in the StudentController it is called in the showForm method? When exactly should the model's setAttribute method be called?
3. In the StudentController' showForm method, what is the point of adding an empty Student object in the model?
There is no definite answer why the setAttribute is used in one method , but not another.
As long as the methods needs to set the attribute and pass it along to the form , then the setAttributed method is used.
Also, Spring form provides some more library tags than html tags. When those library tags are needed to build the front end page, then use it.
Thymeleaf is very popular for building front end for Spring application now.