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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.