[Java] 解決 fastxml “Content type ‘application/json;charset=UTF-8’ not supported”

發生這個問題時, 主要是因為object 中有多個@JsonManagedReference 找到, 因此會令serialize 時不能正常找到相對應的class resolve.

解決方法是在@JsonManagedReference 及相對應的@JsonBackReference 加入value 令其相呼應.

@JsonManagedReference(value="rolePermissionMappings")
  public List<RolePermissionMapping> getRolePermissionMappings() {
    return rolePermissionMappings;
  }
@JsonBackReference(value="rolePermissionMappings")
  public Role getRole() {
    return role;
  }

 

About C.H. Ling 262 Articles
a .net / Java developer from Hong Kong and currently located in United Kingdom. Thanks for Google because it solve many technical problems so I build this blog as return. Besides coding and trying advance technology, hiking and traveling is other favorite to me, so I will write down something what I see and what I feel during it. Happy reading!!!

2 Comments

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.