【发布时间】:2015-04-13 01:03:38
【问题描述】:
我有一个简单的 RESTLET 服务,它返回一个 JSON 表示,如下所示:
@Override
@Post("json")
public Representation helloWorld() {
Representation representation = new JacksonRepresentation<Hello>(new Hello("Hello World"));
representation.setMediaType(MediaType.APPLICATION_JSON);
representation.
return representation;
}
当我使用 cURL 查询时,我得到了预期的响应:
{"greeting":"Hello World"}
但是,当我使用浏览器或 POSTMAN 或任何其他 Web REST 客户端时,我没有得到响应。我收到来自 POSTMAN 的响应“无法得到任何响应”。
POSTMAN 请求的预览是:
POST /testingrestlet/hello HTTP/1.1
Host: 127.0.0.1:6000
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 5141cd87-505c-e813-0045-3b7f4aa54144
我至少希望 POSTMAN 等 REST 客户端能够工作,还是我遗漏了什么?
任何帮助表示赞赏。
问候
【问题讨论】: