81,092
社区成员
发帖
与我相关
我的任务
分享
//Spring 返回json数据
@RequestMapping(value = "/test/json/test_1.json")
@ResponseBody
public JSONObject test_1(){
String str = "{"+ "\"x\":\"value_1\"" + "," + "\"y\":\"value_2\"" + "}";
json = JSON.parseObject(str);
return json;
}
//需求:Spring 返回json文本,提供下载,
//疑问增加produces后,406
@RequestMapping(value = "/test/json/test_1.json", produces = {"text/plain;charset=UTF-8"})
@ResponseBody
public JSONObject test_1(){
String str = "{"+ "\"x\":\"value_1\"" + "," + "\"y\":\"value_2\"" + "}";
json = JSON.parseObject(str);
return json;
}