【发布时间】:2016-03-24 16:46:05
【问题描述】:
我正在使用 Qbit 编写一个简单的 REST 应用程序,但无法正确解析 POST 编辑的文本。这几乎是straight out of a tutorial,所以我不确定我可能会错过什么
在 SimpleService.java 中
@RequestMapping(value = "/body/string", method = RequestMethod.POST)
public boolean bodyPostString(String body) {
return body.equals("foo");
}
...
public static void main(final String... args) {
final ServiceEndpointServer serviceServer = EndpointServerBuilder
.endpointServerBuilder()
.setUri("/")
.build();
serviceServer.initServices(
new SimpleService());
serviceServer.startServer();
在终端中
curl -X POST -H "Content-Type: text/plain" -d 'foo' http://localhost:8080/service/body/string
回复
["Unable to JSON parse body :: false not parsed properly\n\nThe current character read is 'f' with an int value of 102\nfalse not parsed properly\nline number 1\nindex number 0\nfoo\n^"]
【问题讨论】: