Whitelabel Error Page

tech2023-11-20  84

一、写了两个后端的API,测试的时候出现错误:
Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Thu Aug 13 10:36:01 CST 2020 There was an unexpected error (type=Internal Server Error, status=500). No converter for [class com.pccw.data.migration.model.result.BaseResponse] with preset Content-Type 'null'
二、解决方法:
1. 添加@ResponseBody,网上有人说这个可以,我试了不行
2. 把@PostMapping(value = "/integrateArsUser")改为@GetMapping(value = "/integrateArsUser"),不行
3. 添加produces,改成@GetMapping(value = "/integrateArsUser", produces= {}),不行
4. 在类上有注释@RequestMapping,里面有produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE},如下:
@RequestMapping(produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})

去掉MediaType.APPLICATION_XML_VALUE就可以了

5. 直接注释@RequestMapping(produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})也是可以的
三、我这里出现这个问题,主要原因是出现在MediaType这里,因为我本来的接口是只需要返回json数据就可以了,所以就不需要加上APPLICATION_XML_VALUE,这个的意思应该是返回XML之类的数值,但是没有XML页面接收,所以才出错了。
四、总结:如果有疑问可以直接留言评论,如果觉得对你有帮助,可以小小的赞赏一杯奶茶钱,谢谢!!

最新回复(0)