<time-layout time-coordinate="local" summarization="none">
<layout-key>k-p24h-n7-1</layout-key>
<start-valid-time>2015-08-10T08:00:00-04:00</start-valid-time>
<end-valid-time>2015-08-10T20:00:00-04:00</end-valid-time>
<start-valid-time>2015-08-11T08:00:00-04:00</start-valid-time>
<end-valid-time>2015-08-11T20:00:00-04:00</end-valid-time>
<start-valid-time>2015-08-12T08:00:00-04:00</start-valid-time>
<end-valid-time>2015-08-12T20:00:00-04:00</end-valid-time>
<start-valid-time>2015-08-13T08:00:00-04:00</start-valid-time>
<end-valid-time>2015-08-13T20:00:00-04:00</end-valid-time>
<start-valid-time>2015-08-14T08:00:00-04:00</start-valid-time>
<end-valid-time>2015-08-14T20:00:00-04:00</end-valid-time>
<start-valid-time>2015-08-15T08:00:00-04:00</start-valid-time>
<end-valid-time>2015-08-15T20:00:00-04:00</end-valid-time>
<start-valid-time>2015-08-16T08:00:00-04:00</start-valid-time>
<end-valid-time>2015-08-16T20:00:00-04:00</end-valid-time>
</time-layout>
并使用bean转换
public class TimeLayout {
@JacksonXmlProperty( localName = "time-coordinate" , isAttribute = true)
private String timecoordinate;
@JacksonXmlProperty( localName = "summarization" , isAttribute = true)
private String summarization;
@JacksonXmlProperty( localName = "layout-key" , isAttribute = false)
private String key;
@JacksonXmlProperty( localName = "start-valid-time" , isAttribute = false)
@JacksonXmlElementWrapper(useWrapping = false)
private List<String> startvalidtime;
@JacksonXmlProperty( localName = "end-valid-time" , isAttribute = false)
@JacksonXmlElementWrapper(useWrapping = false)
private List<String> endvalidtime;
但是从Jackson库中通过XML Mapper解析 我们只得到一对值(最后一个)
<start-valid-time>2015-08-16T08:00:00-04:00</start-valid-time>
<start-valid-time>2015-08-16T20:00:00-04:00</end-valid-time>
因为每个next或(从一开始)都有自己的上下文并设置之前的值但不会添加到列表中。
答案 0 :(得分:0)
调试映射问题的常用方法是从POJO开始(以编程方式构造实例),然后序列化(写为XML),并查看结构的不同之处。从中可以修改注释,Jackson XML模块配置,或者可能是POJO定义。