我的控制器中有一个方法,应该以JSON返回String。它为非原始类型返回JSON:
@RequestMapping(value = "so", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<String> so() { return new ResponseEntity<String>("This is a String", HttpStatus.OK); }
卷曲响应为:
This is a String
@RequestMapping(value = "so", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody String so() { return "This is a String"; }