How to do it...

To implement form handling using Spring 5, perform the following steps:

  1. Let us first implement the model object that will contain all request data during form transactions. The form_page handles all the HTML components that will receive all request parameters from the client. To organize these numerous parameters during the request dispatch, it will be ideal if we create a form model or form backing object to persist all this data. This strategy can avoid a convoluted declaration of request parameters at the @Controller level. So, before creating the physical view and the @Controller, write this POJO first, containing all the data and its properties:
public class EmployeeForm { private String firstName; private String lastName; ...

Get Spring 5.0 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.