springspring-bootspring-mvc-initbinders

Spring initbinder register multiple custom editor String.class


I have following initBinder in my ControllerAdvice class

 @InitBinder
    public void initBinder(WebDataBinder binder) {
        binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
        binder.registerCustomEditor(String.class, new HtmlEscapeStringEditor());
    }

String trimmer stopped working when I added HtmlEscapeStringEditor to my init binder. Is there any way how to register multiple custom editores over one class?

Thanks for answers


Solution

  • Perhaps not the most elegant solution, but it worked for me. I have created new class that combined functionalities of both HtmlEscapeStringEditor and StringTrimmerEditor