首页 > 其他分享 >SpringMVC返回JSON对象遇到的错误

SpringMVC返回JSON对象遇到的错误

时间:2023-03-20 11:23:15浏览次数:35  
标签:返回 produces SpringMVC text json JSON

SPringMVC返回JSON对象遇到报错:org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.logException Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter for [class java.util.ArrayList] with preset Content-Type 'null']

错误代码

  @RequestMapping(value = "/test" , produces = {"text/html" , "application/json"})

改正后

  @RequestMapping(value = "/test" , produces = {MediaType.APPLICATION_JSON_VALUE})

错误原因

SpringMVC在解析返回对象的时候produces属性的text/html和application/json有冲突

标签:返回,produces,SpringMVC,text,json,JSON
From: https://www.cnblogs.com/yuehuo9426/p/17235630.html

相关文章