Spring initbinder register multiple custom editor String.class

784 Views Asked by At

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

1

There are 1 best solutions below

0
Marek Sekyra On BEST ANSWER

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