我正在使用托管在远程服务器上的 REST Web 服务。 现在,Web 服务的 POST、PUT 和 DELETE 方法被服务器的防火墙阻止。所以我只剩下GET方法了。 有没有办法可以使用 GET 来作为 POST 或 PUT 或 DELETE 工作? 我正在使用 jersey api 来使用服务。
最佳答案
https://groups.yahoo.com/neo/groups/rest-discuss/conversations/messages/9962
Yes. In other words, any HTTP request message is allowed to contain a message body, and thus must parse messages with that in mind. Server semantics for GET, however, are restricted such that a body, if any, has no semantic meaning to the request. The requirements on parsing are separate from the requirements on method semantics.
So, yes, you can send a body with GET, and no, it is never useful to do so.
This is part of the layered design of HTTP/1.1 that will become clear again once the spec is partitioned (work in progress). ....Roy
这意味着您可以使用 GET 请求发送消息正文,但它没有任何意义。如果您的服务器防火墙不允许您接收除 GET 之外的请求,您应该尝试与您的管理员联系,更改服务器,如果由于公司原因而无法做到这一点,您应该通过您的经理将其升级。
编辑:正如卡亚曼所说,这不是你的工作。如果没有合适的基础设施,你就无法工作。如果没有给您一台计算机,没有人会指望您能够编码。
关于java - 使用 GET 方法进行 POST、PUT 或 DELETE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31334385/