我有一个休息服务,具有以下实施 -
>>> from django.contrib.gis.geos import LineString, MultiLineString
>>> DATA = [[36.66678428649903, -1.5474249907643578], [36.670904159545906, -1.542620219636788], [36.66635513305665,-1.5353272427374922],[36.662406921386726, -1.5403894293513378]]
>>> line = LineString(DATA)
>>> line
<LineString object at 0x7f96538f49a0>
>>> line.length
0.02134446840090856
>>> line.geojson
'{ "type": "LineString", "coordinates": [ [ 36.666784286499031, -1.547424990764358 ], [ 36.670904159545906, -1.542620219636788 ], [ 36.666355133056648, -1.535327242737492 ], [ 36.662406921386726, -1.540389429351338 ] ] }'
>>> multi_line = MultiLineString(line)
>>> multi_line
<MultiLineString object at 0x7f96536ccbc0>
>>> multi_line[0]
<LineString object at 0x7f964187b3c8>
>>> multi_line.length
0.02134446840090856
>>> multi_line.geojson
'{ "type": "MultiLineString", "coordinates": [ [ [ 36.666784286499031, -1.547424990764358 ], [ 36.670904159545906, -1.542620219636788 ], [ 36.666355133056648, -1.535327242737492 ], [ 36.662406921386726, -1.540389429351338 ] ] ] }'
>>> from myapp.models import LogsUpload
>>> o = LogsUpload(name="foo", geom=multi_line)
>>> o.full_clean()
>>> o.save()
我正确获取所有标头和响应状态,但我没有收到json响应。这有什么不对?
我正在尝试做以下事情 - https://stackoverflow.com/a/23736527/2197994
在嵌套调用的深处,我使用spring rest模板从其他后端获得响应。
@RequestMapping(method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@JsonSerialize
public ResponseEntity<String> handleData(HttpMethod method, HttpServletRequest httpRequest)
throws URISyntaxException, IOException {
BackendRequest request = new BackendRequest();
request.setHttpRequest(httpRequest);
request.setMethod(method);
BackendResponse backendResponse = service.getresponse(request);
ResponseEntity<String> response = backendResponse.getResponse();
return new ResponseEntity<String>(response.getBody(), response.getHeaders(), response.getStatusCode());
// return response;
}
答案 0 :(得分:0)
BackendResponse backendResponse = service.getresponse(request)
可能是问题所在。你可以发布方法的内容吗?