Kevin Rave Kevin Rave - 5 months ago 135
Java Question

@Valid annotation - This annotation disallowed for this location

I have controller method that has

@Valid
annotation to enforce JSR303 Bean validation.

But when I just give
@Valid
is shows"

This annotation @Valid is disallowed for this location


I can get rid of this by giving full package path
@javax.validation.Valid
. It does not show the above message if I use this.

My question is, would there be any conflict that is forcing me to give full package name?
Or some jars missing?

I wouldn't be asking this question, if
@Valid
validation is working fine. But its not working either, though there is no compile or run time error. It is just not triggering.

I posted this issue here in a different thread.

Answer

Take a look at your imports. I guess you are not importing javax.validation.Valid when you just use @Valid.