Mar*_*ior 1 rest json jax-ws jersey
我是泽西和REST的新手所以请原谅,如果我的问题太愚蠢了.我有一个名为Places的简单资源,它应该支持一个GET基于输入变量返回一些兴趣点的操作.这是输入字符串和类:
错误:
HTTP 415 - Unsupported Media Type
Run Code Online (Sandbox Code Playgroud)
输入网址:
http://localhost:8080/RESTGO/rest/places?latitude=2&longitude=3&radius=3&types=food
Run Code Online (Sandbox Code Playgroud)
类:
@Path("/places")
public class Places {
@GET
@Produces(MediaType.APPLICATION_JSON)
public JSONObject getPlaces(@QueryParam("latitude") double latitude,
@QueryParam("longitude") double longitude,
@QueryParam("radius") int radius,
@QueryParam("types") String types,
@DefaultValue("true") boolean sensor) {
GooglePlacesClient google = new GooglePlacesClient();
JSONObject json = null;
try {
String response = google.performPlacesSearch(latitude, longitude, radius, types, sensor);
json = new JSONObject(response);
} catch (Exception e) {
e.printStackTrace();
}
return json;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3000 次 |
| 最近记录: |