Issue
Does anybody has an idea about how I can return an error message. I am trying to return an specific xml error message in my validator. This is my code:
@Override
public void validate(Object target, Errors errors) {
try {
ValidationClassUtil.validateDocument(new String((byte[]) target), xmlVersionEnum);
(//should the error be returned here when I send an invalid xml file over http?)
} catch (Exception exc) {
errors.reject(errorCode);
}
}
Solution
This is not what Validator
contract is for. You cannot return from it anything. You can use such a validate()
in other wrapper service and then in the end you consult that errors
to be able to return whatever you want via its hasErrors()
and getAllErrors()
.
I have showed you some way in this answer: Validator Spring integration
Answered By - Artem Bilan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.