我正在尝试发送请求以取回对象数组-Coupon当我提交请求时,我得到了答案-
直接自引用导致循环(通过引用链: java.util.HashSet[0]=> model.Coupon["emptyCoupon"]=> model.Coupon["emptyCoupon"])
model.Coupon可能会解决问题。如果请求的优惠券不存在,则打算退回空优惠券。
public static final int NO_ID = -1;
private static final Coupon EMPTY_COUPON = new Coupon(NO_ID, null, null, null, NO_ID, NO_ID, null, NO_ID, null);
private long id = NO_ID;
private String title;
private LocalDate startDate;
private LocalDate endDate;
private int amount;
private int category;
private String message;
private double price;
private String image;
public Coupon() {
}
private Coupon(long id, String title, LocalDate start_date, LocalDate end_date, int amount, int category,
String message, double price, String image) {
this.id = id;
this.title = title;
this.startDate = start_date;
this.endDate = end_date;
this.amount = amount;
this.category = category;
this.message = message;
this.price = price;
this.image = image;
}
public Coupon getEmptyCoupon() {
return EMPTY_COUPON;
}
在我添加之前,我EMPTY_COUPON对请求没有任何问题。我想要代码中的emptyCoupon,我很乐意提供帮助
智慧大石
相关分类