报错信息如下:
2024-02-02 16:58:29.832 ERROR 15768 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.http.converter.HttpMessageNotWritableException: No converter for [class com.pxl.bg_system.common.Result] with preset Content-Type 'text/plain'] with root cause
问题原因:
所以只需要配置一个 MappingJackson2HttpMessageConverter
转换器来处理 Result
类型的数据。这个转换器可以将 Java 对象序列化为 JSON 格式,并将其包含在响应体中。
温馨提示: