StringTrimmerEditor

Learn how to handle extra spaces using the built-in StringTrimmerEditor.

We'll cover the following

The problem

The users of an application might add one or more extra spaces when they need to input some data.

Using StringTrimmerEditor

We could make sure to trim these extra spaces in each of the form data backing objects, but that would get tedious fast.

Instead we’ll use:

org.springframework.beans.propertyeditors.StringTrimmerEditor

Let’s add this to GlobalControllerAdvice so that it is enabled for all controllers in the application:

Get hands-on with 1200+ tech skills courses.