全部, 我正在尝试生成xml输出,如 -
<Row>
<City>Boston</City>
<Runners>7000</Runners>
</Row>
xsd生成的类型是:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "RowType", propOrder = {
"any"
})
public class RowType {
@XmlAnyElement(lax = true)
protected List<Object> any;
public List<Object> getAny() {
if (any == null) {
any = new ArrayList<Object>();
}
return this.any;
}
}
Unmarshalling工作正常,而编组则会产生如下输出。
<Row>
<any>
<name>CITY</name>
<declaredType>java.lang.String</declaredType>
<scope>javax.xml.bind.JAXBElement$GlobalScope</scope>
<value>Boston</value>
<nil>false</nil>
<globalScope>true</globalScope>
<typeSubstituted>false</typeSubstituted>
</any>
<any>
<name>RUNNERS</name>
<declaredType>java.lang.String</declaredType>
<scope>javax.xml.bind.JAXBElement$GlobalScope</scope>
<value>7000</value>
<nil>false</nil>
<globalScope>true</globalScope>
<typeSubstituted>false</typeSubstituted>
</any>
</Row>
知道如何使用Spring启动工作吗?
答案 0 :(得分:0)
生成的POJO不对。应该是
<强> ROWTYPE:强>
public class RowType
{
private Row Row;
public Row getRow ()
{
return Row;
}
public void setRow (Row Row)
{
this.Row = Row;
}
@Override
public String toString()
{
return "ClassPojo [Row = "+Row+"]";
}
}
Row.java:
public class Row
{
private String Runners;
private String City;
public String getRunners ()
{
return Runners;
}
public void setRunners (String Runners)
{
this.Runners = Runners;
}
public String getCity ()
{
return City;
}
public void setCity (String City)
{
this.City = City;
}
@Override
public String toString()
{
return "ClassPojo [Runners = "+Runners+", City = "+City+"]";
}
}
使用此工具进行交叉检查:http://pojo.sodhanalibrary.com/Convert