I'm using the Jersey implementation for JAX-RS, and I was looking for an example where I can use the Bean Validation in POST requisitions. I have this operation, for example:
@POST
@Path("document/annotations/save")
@Produces("application/json")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Map<String, Object> saveAnnotation(
@FormParam("user") String userStr,
@FormParam("documentId") String documentId,
@FormParam("documentPage") Integer documentPage,
@FormParam("annotationContent") String annotationContent,
@FormParam("annotationId") Long annotationId,
@FormParam("isMobile") Boolean isMobile) { // the code... }
I wanna use validations constraints (@NotNull
, @Pattern
, etc) for each method param. I saw this doc where they're using the Seam Framework to do that.
Currently, I'm trying to use the javax.validation
implementation to validate my requests, but it doesn't working.
Is there a way to use the JSR-303 specification with JAX-RS?
Tnks.
AspectJ
? - Willy