How to send a HTTP error for a Java RESTful web service?

前端 未结 1 1726
悲哀的现实
悲哀的现实 2021-01-06 13:40

I have done this tutorial and now I want to throw an error from this webservice, like HTTP error code 403 or 400.

How can i do this? I noti

相关标签:
1条回答
  • 2021-01-06 14:31

    You can do it like this.

    @GET
    public Response check(@QueryParam("username") String username) {
       if (facade.checkUser(username)) {
          return Response.status(Response.Status.NOT_FOUND).build();
       }
       return Response.ok().build();
    }
    
    0 讨论(0)
提交回复
热议问题