In Java RESTful service request parameter validation, an error should be thrown if the required parameters does not exist in the request payload.
I've tried the following but it didn't work:
public class OrderItemDetailsDTO {
@XmlElement(required = true)
private long orderItemId;
// getters and setters...
}
I also tried @NotNull
, @min(1)
, but none of them worked. The URL is called and method executes even if the required parameter is not present and then the method throws an exception which I don't want.
Is there any way so that the error is thrown, saying required element is not present, before going to the method?...