当向POST
我的 Play 框架操作方法发出具有大主体的请求时,我null
在提取数据时得到。如果主体相当小,我可以很好地检索数据。
这是一个简短的数据集示例:
{
"creator": "zoltan",
"sport": "hike",
"geometry": [
{
"time": "2009-07-10 12:56:10 +0000",
"x": 10.275514,
"y": 47.514749,
"z": 756.587
},
{
"time": "2009-07-10 12:56:19 +0000",
"x": 10.275563,
"y": 47.514797,
"z": 757.417
}
]
}
当我在正文中使用此 JSON 发出POST
请求时,一切正常。geometry
但是,如果我在数组中添加更多(~4000)点,我就会null
参与其中。
这是我的操作方法:
@Transactional
//@BodyParser.Of(Json.class) // tried with this as well
public static Result createTour() {
LOG.debug("Raw request body: " + request().body().asText());
JsonNode node = request().body().asJson();
LOG.debug("JSON request body: " + node);
TourDto tourDto;
try {
tourDto = jsonToTour(node);
int id = TourDataAccessUtils.create(tourDto);
return created(toJson(id));
} catch (JsonProcessingException e) {
LOG.error("While parsing JSON request.", e);
return Results.badRequest(
toJson(Throwables.getRootCause(e).getMessage()));
}
}
我尝试在 chrome 中使用 Advanced REST Client 并ċurl
发送请求,但都失败了。
可能是什么问题呢?可能是我需要Content-Lenght
为大型请求包含一个标头吗?如果是这样,我如何手动计算任意 JSON 数据?