java - Spring Validator does not support command class -


i think issue pretty common, reason cannot manage fix this.

this error getting:

org.springframework.beans.factory.beancreationexception: error creating bean name 'reversecontroller' defined in servletcontext resource [/web-inf/app-servlet.xml]: initialization of bean failed; nested exception java.lang.illegalargumentexception: validator [formvalidator@6b3ded0d] not support command class [reversestring] 

this supports method in formvalidator class:

public boolean supports(class clazz) {     return reversecontroller.class.isassignablefrom(clazz); } 

this bean definition on app-servlet.xml:

<bean id="reversecontroller" class="reversecontroller">         <property name="commandname"><value>reversestring</value></property>    <property name="commandclass"><value>reversestring</value></property>            <property name="formview"><value>reverse</value></property>    <property name="successview"><value>reverseresult</value></property>    <property name="validator"><bean class="formvalidator" /></property> 

and finally, main part of reversecontroller:

 @service public class reversecontroller extends simpleformcontroller {      public reversecontroller() {         //setcommandclass(reversestring.class);         //setcommandname("reversestring");     }      private reversestring reversestringmaster;      @autowired     public void setwriter(reversestring reversestringmaster) {         this.reversestringmaster = reversestringmaster;     }      protected modelandview onsubmit(httpservletrequest request,         httpservletresponse response, object command, bindexception errors) {          reversestring revstring = (reversestring) command;          return new modelandview(getsuccessview(),"reversedstring",  revstring);     }      public void init() {         system.out.println("done");     }   } 

any idea might causing issue?

it's instance of command class gets validated on each request - gets populated form data. controller not validated.

so supports() method in formvalidator should read:

public boolean supports(class clazz) {     return reversestring.class.isassignablefrom(clazz); } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -