#... java.lang.Illegal State Exception: Cannot call sendError() after the response has been committed #...
BusinessTemplate.javajava
// ... @OneToMany(targetEntity = Link.class, mappedBy = "businessTemplate", fetch = FetchType.EAGER) private List<Link> links; // ...
Link.javajson
//... @ManyToOne private BusinessTemplate businessTemplate; //...
若是在LinkController中直接查询Link对象会出现json无限递归问题。bash
分别在父子类中添加以下注释: BusinessTemplate.javaapp
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") public class BusinessTemplate { //... }
Link.javafetch
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") public class Link { //... }
{ "id": 4, "name": "环节名称", "businessTemplate": { "id": 2, "name": "预算业务", "type": "业务类型1", "links": [ 4 ] }, "nextLinkId": 0, "previousLinkId": 0 }
{ "id": 2, "name": "预算业务", "type": "业务类型1", "links": [ { "id": 4, "name": "环节名称", "businessTemplate": 2, "nextLinkId": 0, "previousLinkId": 0 } ] }