Spring content-type = utf8 错误如何解决?

问题描述 投票:0回答:1

“org.springframework.web.HttpMediaTypeNotSupportedException:不支持内容类型'application/json;charset=UTF-8' 在org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:213) 在org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:159)

我尝试提供 @JsonManagedReference 和 @JsonBackReference 注释

spring spring-boot
1个回答
0
投票

这个错误是非常小的错误,只是不要使用通用映射而是使用@Get @Post @Put 等非常具体的映射而不是@RequestMappings

你也可以尝试一下

@JsonIgnoreProperties({其中包含所有引用变量|我重复一遍不要错过任何})

以上2步即可解决问题

enter image description here

  @JsonIgnoreProperties({"books_in_trans_table", "bookList_S","bookList_A","authored_by" ,"students_in_trans_table", "my_student","transactionList_B","transactionList_S" })
    @ManyToOne
    @JoinColumn
    private Author authored_by;
© www.soinside.com 2019 - 2024. All rights reserved.