问题
I have a method that's receive two parameters: id
from type Long and name
from type String. I need to validate if name is not null with @NotNull from
javax.validation.constraints.NotNull
and if it is null I need to return the status code http 400.
This is my implementation.
@GET
@Path(URI.route)
@Produces(MediaType.APPLICATION_JSON)
Response data(@PathParam("id") Long name,
@PathParam("name") @NotNull String name) throws Exception;
Currently it's return https status code 500.
Any idea how I do this?
来源:https://stackoverflow.com/questions/52281666/how-to-return-400-http-status-code-with-notnull