How to do it...

To apply form validation and input type conversion, do the following procedures:

  1. The validation process will progress after modifying the EmployeeForm form model of the previous recipe to contain three more request data, namely the email, age, and birthday of the employee:
public class EmployeeForm { 
  
  private String firstName; 
  private String lastName; 
  private String position; 
 
  // additional information 
  private Integer age; 
  private Date birthday; 
  private String email; 
 
  // getters and setters 
} 
Primitive types are not recommended in declaring form model properties because form validation and type conversion works easily with object types. Thus, wrapper classes must be used instead of their primitive counterparts.
  1. The most straightforward ...

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.