surroundings
Java 1.8
SpringBoot 2.1.9
Java interface code
@ResponseBody @RequestMapping(value = "cloud", method = RequestMethod.GET,produces = "applications/json;charset=UTF-8") public Boolean queryItemInfoAllInCloud(){ ItemInfo itemInfo = itemService.queryItemInfoAllInCloud(); if(itemInfo == null) return false; return true; }
Request path
http://127.0.0.1:8080/controller/cloud/
Warnings
2019-11-14 14:56:57.465 WARN 57604 Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation]
This sentence translates to "Can not find an acceptable representation" can be understood as the browser can not find the right type of request to display the return value interface?
Then the problem is in
produces = "applications/json;charset=UTF-8"
This code means that the type of return json response data, but we return a Boolean value of the interface is, of course, can not be returned
So to change this code
produces=MediaType.APPLICATION_JSON_VALUE
A satisfactory solution to the problem