When using regex for @Path fragments, Jersey runtime results in returning 404 for the resources that do not match the regex pattern. Is there a way to customize this behaviour and return 400 (BAD_REQUEST) or add a meaningful message to the response?
@Path("users/{username: [a-zA-Z][a-zA-Z_0-9]}")
If the resource is invoked with users/1243 it results in 404. I would like to add a response message about the valid username patterns. I could move the validation inside the Restful method and validate. But this is tedious. I have dozens of the methods and I would need to call the validation from all these methods.
EDIT: Am using Jersey 1.17 and not can not use Jersey 2.0 due to application impact.