java - 使用 GET 方法进行 POST、PUT 或 DELETE

标签 java rest

我正在使用托管在远程服务器上的 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/

相关文章:

Java Swing布局问题

java - C 中的按位运算符 ~=

java - java stringtokenizer - 性能

java - 有没有办法为 RESTful 堆栈生成样板代码?

c# - WSDL2REST - 有 C# 版本吗? (将 SOAP 转换为 RESTful Web 服务)

java - 比较对象的更详尽的方法

java - Windows 上的 Docker 引擎会忽略 Spring Boot Web 应用程序的 server.port 属性

python - Django REST Framework - 在创建时序列化嵌套关系

java - 当我发送休息请求时,为什么我收到 http 错误代码 500

html - Visual Studio 2010 的简单 HTML 项目类型