How to create a Restful web service with input parameters?

前端 未结 5 740
花落未央
花落未央 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:24

    If you want query parameters, you use @QueryParam.

    public Todo getXML(@QueryParam("summary") String x, 
                       @QueryParam("description") String y)
    

    But you won't be able to send a PUT from a plain web browser (today). If you type in the URL directly, it will be a GET.

    Philosophically, this looks like it should be a POST, though. In REST, you typically either POST to a common resource, /todo, where that resource creates and returns a new resource, or you PUT to a specifically-identified resource, like /todo/, for creation and/or update.

提交回复
热议问题