Springboot:不将JSON打印到Web应用程序

时间:2016-08-16 15:40:26

标签: java json spring-boot

我有一个简单的Web应用程序,我正在尝试打印JSON对象但是当我转到该链接时,我得到 WhiteLabel错误页面

这是我的控制器Java代码:

@Controller
public class WsdlController {
@RequestMapping(value = "/getReport", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
public ResponseEntity<JSONObject> getMyResponse() throws ClientProtocolException, IOException {
    String url = "this url has JSON data";
    JSONObject json = null;
    try {
        json = new JSONObject(IOUtils.toString(new URL(url).openStream()));
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return new ResponseEntity<JSONObject>(json, HttpStatus.OK);
 }
}

因此,当我运行它并转到localhost:8080/getReport时,我收到此错误:

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Aug 16 11:31:21 EDT 2016
There was an unexpected error (type=Not Acceptable, status=406).
Could not find acceptable representation

0 个答案:

没有答案