public class BoardValidator implements Validator {
@Autowired
BoardService boardService;
@Override
public boolean supports(Class<?> clazz) {
return BoardVO.class.equals(clazz);
}
@Override
public void validate(Object target, Errors errors) {
boardService.getAllList();
//TODO add
}
}
像这样创建验证器
可以在控制器包中使用boardService
但在验证器中,boardService为Null
如何在Validator类中使用Service @Autowired?