Hibernate validator: Failed to customize messages
This question would seem like being answered tons of time already but I
have not been able to get it to work with any of the answers posted either
in this forum or else where.
I am developing a RESTful interface with JSR303/Hibernate validator for
the parameter validation. Validation is working as intended but my custom
messages are not being used.
It seems like both hard-coded/ValidationMessages.properties are not used
and I get a generic "Missing parameter" error message in the response.
I have created ValidationMessages.properties and have added it to the
classpath. Nothing I do seems to pick up the ValidationMessages.properties
file or my hard-coded messages.
Dependencies for Validation:
<!-- Parameter validation -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
Servlet Code:
@Path("/validation/test")
@POST
@Consumes(CONSUMES)
@Produces(PRODUCES)
public Response validate(
@NotNull(message = "{callback.notnull}") @FormParam(Params.CALLBACK)
UriParam callback,
@NotNull @FormParam(Params.MODE) ModeParam mode,
@FormParam(Params.VERIFY) String verifyToken) {
...
}
Did anybody else ran into same issue? Any help would be deeply appreciated.
Thank you!
No comments:
Post a Comment