SimpleModule module = new SimpleModule(); module.addDeserializer(Page.class, new JsonDeserializer<Page>() { @Override public Page deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { return null; } }); objectMapper.registerModule(module); 试下加上这个
[quote=引用 5 楼 long_539437 的回复:] 设置FAIL_ON_EMPTY_BEANS属性,告诉Jackson空对象不要抛异常; mapper.disable(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS);
[quote=引用 6 楼 iludan 的回复:] [quote=引用 5 楼 long_539437 的回复:] 设置FAIL_ON_EMPTY_BEANS属性,告诉Jackson空对象不要抛异常; mapper.disable(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS);
设置FAIL_ON_EMPTY_BEANS属性,告诉Jackson空对象不要抛异常; mapper.disable(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS);
你的User 类也要继承一下序列化接口
67,513
社区成员
225,880
社区内容
加载中
试试用AI创作助手写篇文章吧