1
在具有Integer屬性的類的對象列表中存在序列化問題。SpringBoot:在序列化時失敗Integer類
唯一的例外是:
Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Could not write content: (was java.lang.NullPointerException) (through reference chain: java.util.ArrayList[0]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: java.util.ArrayList[0])
類是:Discipline.java
public class Discipline extends AbstractModel {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private String course;
private Integer teoricLoad;
private Integer exerciseLoad;
private Integer labLoad;
// Ignored getters and setters
}
我檢查的對象和學科名單的arent空只是整數屬性。
你怎麼想序列化它們? – jpganz18
@ jpganz18通過控制器映射中的註釋ResponseBody自動序列化。 – Alvadorn
您可以添加更多有關您的問題的細節,但尚不清楚。您是否在使用服務並嘗試撥打它? –