How to return 400 http status code with @NotNull?

纵饮孤独 提交于 2021-02-08 07:35:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!