使用 REST 是否必须使用适当的方法类型(POST、PUT、GET、DELETE)? [英] Is it mandatory to use appropiate Method Types (POST , PUT , GET , DELETE) using REST?

查看:28
本文介绍了使用 REST 是否必须使用适当的方法类型(POST、PUT、GET、DELETE)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在我们的项目中使用 REST 调用 Web 服务来处理从用户界面发出的所有调用

We are using REST call Webservices in our Project for all the calls made from User Interface

目前每个方法的签名都是这样配置的

Currently for every method the signature is configured in this way

public class SaveNewAddressLabelService {
    @GET
    @Consumes("application/text")
    @Produces("application/json")

表示即使方法执行了 SELECT ,INSERT , UPDATE ,DELETE 操作,它也使用 GET 进行了注释.

Means even if the Method performs a SELECT ,INSERT , UPDATE ,DELETE Operation it was annotated using GET .

一切正常,如果我使用适当的方法,你能告诉我它会有什么不同吗发布、放置、获取、删除

Everything works fine ,could you please let me know will it make any difference if i use appropiate Method like POST , PUT , GET , DELETE

推荐答案

嗯,在功能方面可能没有区别.但是,如果您想将 API 发布为 RESTful,则使用标准 REST 方法是很好的.使用您的 API 的人有一些基于标准的期望(即 GET 方法是幂等的 - 不会改变状态)并且他们可能会混淆使用您的 API.

Well, in the terms of functionality there may not be a difference. However using standard REST methods is good if you want to publish your API as RESTful. People using your API have some expectations base on the standard (i.e. GET method is idempotent - doesn't change the state) and it may be confusing for them to work with your API.

这篇关于使用 REST 是否必须使用适当的方法类型(POST、PUT、GET、DELETE)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆