Custom Editors and Formatters

Learn how custom formatters can be used to directly bind to richer objects.

We'll cover the following

With Spring MVC and Thymeleaf, we have to convert Java objects from the HTML <input> values. Using String on the FormData objects makes this process trivial.

However, there might be cases where we want to bind to a richer object directly. This can be done by implementing a custom property editor or a custom formatter.

Custom editor

We’ll use PhoneNumber as an example. In AbstractUserFormData, we currently have this:

Get hands-on with 1400+ tech skills courses.