问题描述
我有这样的课程
public class Book {
private String contributor;
private String nocontributor;
private String edition;
private String noedition;
}
如果该书的作者为John Doe,并且版本为First Edition,则现在可以从数据库中获取该书的信息。然后可以将该对象转换为xml,例如:
<Contributor>John Doe</Contributor>
<Edition>First Edition</Edition>
或者,如果该书没有包含贡献者和版本信息,则返回xml应该是:
<NoContributor/>
<NoEdition/>
我尝试使用如下注释:
@JsonInclude(JsonInclude.Include.NON_NULL)
返回xml将忽略所有字段。
如果我不使用注释,则返回xml会:
<Contributor/>
<NoContributor/>
<Edition/>
<NoEdition/>
请提出可能的解决方案。 谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)