Spring beans属性绑定错误

时间:2012-04-13 13:30:07

标签: spring-mvc

org.springframework.beans.factory.BeanCreationException:在ServletContext资源[/WEB-INF/tracker-servlet.xml]中定义了名为'workingTimeController'的bean创建错误:bean的初始化失败;嵌套异常是java.lang.IllegalArgumentException:Validator [de.intec.tracker.controller.WorkingTimeController@4610fa]不支持命令类[de.intec.tracker.dto.WorkingTimeDTO]

工作控制器是java中的控制器类

1 个答案:

答案 0 :(得分:0)

您可以定义如下代码段

LoginFormCommand     com.aims.commands.LoginFormCommand      

和验证器应该使用验证器接口,如下面的代码片段

公共类LoginFormValidator实现Validator {

public boolean supports(Class arg0) {
    // TODO Auto-generated method stub
    return LoginFormCommand.class.equals(arg0);

}

public void validate(Object obj, Errors errors) {
    // TODO Auto-generated method stub
    LoginFormCommand login = (LoginFormCommand) obj;
    System.out.println("validate==============");
    ValidationUtils.rejectIfEmpty(errors,"username","field.required", "Required field");
    ValidationUtils.rejectIfEmpty(errors,"password","field.required", "Required field");
    }

}