Invalid target for Validator in spring error?

后端 未结 1 475
不知归路
不知归路 2021-01-12 12:09

Hi all I am getting the following error whenever I am trying to invoke validator in my spring

Servlet.service() for servlet spring threw exception: java.lang         


        
相关标签:
1条回答
  • 2021-01-12 12:30

    The problem is actually in Validator class you are using NewUserRegistration's object which is wrong because you want to validate your User's object not your NewUserRegistration's object.

    @Override
        public boolean supports(Class<?> classz) 
        {
            return NewUserRegistration.class.equals(classz);
        }
    

    which should be

    @Override
        public boolean supports(Class<?> classz) 
        {
            return User.class.equals(classz);
        }
    
    0 讨论(0)
提交回复
热议问题