How can I trim spaces from request parameters in Spring MVC

I am struggling to believe that my need to trim leading and trailing spaces from the query parameters is not a general requirement, and yet I cannot find anyone who has a good answer to its solution.

Of course, is there an easy way to customize, say, Spring WebDataBinderto trim all spaces from parameter values ​​before matching them with the target?

I would really like to know how other people handled this.

+5
source share
1 answer

You can try to register a user PropertyEditorinWebDataBinder

 registerCustomEditor(String.class, propertyEditor)

StringTrimmerEditor .

+5

All Articles