How to send form fields from jsp to server in Spring MVC / How to submit a form to Spring Controller
codippa
Suppose we have a jsp page which has a form whose data should be sent to the server. The form has fields which are directly related to the fields of an entity on the server. An entity is a simple java class which has some fields and their getter and setter methods.
Let’s say the entity is a User (which means we have a User class on the server and each field of the jsp form is linked to a field of User class. When we say linked, it simply means that the name attribute of the form element is the same as the name of the corresponding entity field.
We just enter the values and save the form and all the form fields should be sent to the server. The jsp page would look something like:
This comprises of a simple html form tag along with various input boxes. The code would look something like: