How to create a Restful web service with input parameters?

前端 未结 5 727
花落未央
花落未央 2020-12-24 02:47

I am creating restful web service and i wanted to know how do we create a service with input parameters and also how to invoke it from a web browser.

For example

5条回答
  •  粉色の甜心
    2020-12-24 03:30

    You can. Try something like this:

    @Path("/todo/{varX}/{varY}")
    @Produces({"application/xml", "application/json"})
    public Todo whatEverNameYouLike(@PathParam("varX") String varX,
        @PathParam("varY") String varY) {
            Todo todo = new Todo();
            todo.setSummary(varX);
            todo.setDescription(varY);
            return todo;
    }
    

    Then call your service with this URL;
    http://localhost:8088/JerseyJAXB/rest/todo/summary/description

提交回复
热议问题