最外层xml节点类:
import java.util.List;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Chart {
private String XAxisName;
private List<Dataset> dataSet;
private Categories categories;
public List<Dataset> getDataSet() {
return dataSet;
}
public void setDataSet(List<Dataset> dataSet) {
this.dataSet = dataSet;
}
public Categories getCategories() {
return categories;
}
public void setCategories(Categories categories) {
this.categories = categories;
}
@XmlAttribute
public String getXAxisName() {
return XAxisName;
}
public void setXAxisName(String axisName) {
XAxisName = axisName;
}
}
第二层节点类:
import java.util.List;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Dataset {
private String seriesName;
private List<Set> sets;
@XmlAttribute
public String getSeriesName() {
return seriesName;
}
public void setSeriesName(String seriesName) {
this.seriesName = seriesName;
}
@XmlElement(name="set")
public List<Set> getSets() {
return sets;
}
public void setSets(List<Set> sets) {
this.sets = sets;
}
}
三层:
import java.util.List;
public class Categories {
private List<Category> category;
public List<Category> getCategory() {
return category;
}
public void setCategory(List<Category> category) {
this.category = category;
}
}
四层:
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Category {
private String label;
@XmlAttribute
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
}
生成结果如附件
分享到:
相关推荐
当前项目包含一套生成指定格式的xml 字符串内容,以及根据返回的字符串生成指定格式的map格式的内容;
JDK注解@XmlRootElement
@XmlRootElement(name = "xml") @XmlAccessorType(XmlAccessType.FIELD) public class Message { /** * 开发者微信号 */ @XmlElement(name = "ToUserName") private String toUserName; /** * 发送方帐号...
JAXB能够使用Jackson对JAXB注解的支持实现(jackson-module-jaxb-annotations),既方便生成XML,也方便生成JSON,这样一来可以更好的标志可以转换为JSON对象的JAVA类。JAXB允许JAVA人员将JAVA类映射为XML表示方式,...
JAXB能够使用Jackson对JAXB注解的支持实现(jackson-module-jaxb-annotations),既方便生成XML,也方便生成JSON,这样一来可以更好的标志可以转换为JSON对象的JAVA类。JAXB允许JAVA人员将JAVA类映射为XML表示方式,...
JAXB能够使用Jackson对JAXB注解的支持实现(jackson-module-jaxb-annotations),既方便生成XML,也方便生成JSON,这样一来可以更好的标志可以转换为JSON对象的JAVA类。JAXB允许JAVA人员将JAVA类映射为XML表示方式,...
JSON 和 XML 服务都在工作……感谢 bean 类上的 @XmlRootElement 注释。 0.0.1-M3 使用 Spring Boot 的 JAX-WS SOAP 服务(代码优先)。 0.0.1-M4 使用 SOAPHandler 并通过 Spring Boot 进行日志记录。 JAX-WS ...
概要该库基于项目提供的功能,提供了流畅的JUnit / Hamcrest匹配器以进行XML比较。程式码范例public class XmlMatcherExampleTests { @XmlRootElement ( name = " foo " ) public static class MyJaxbThing { public...
使用Maven原型生成来生成球衣项目。 创建模型客户,产品,位置,订单 创建资源CustomerResource,CatalogueResource,LocationResource,OrderResource 创建服务CustomerService,CatalogueService,Location...
import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name=getWeatherbyCityName,namespace=http://WebXml.com.cn/) public class CityReq { private String theCityName; public String getTh
java版女精灵源码使用 Eclipse ...Setter”来生成Getter/Setter。 添加toString实现 更新后的类应如下所示: @Entity @XmlRootElement @NamedQuery ( name = " findAllStudents " , query = " select s
#Jersey-2 with Guice ... @XmlRootElement @XmlAccessorType ( XmlAccessType . FIELD ) @Entity public class User implements Serializable { private static final long serialVersionUID = 366534908950086
低于年份值必须等于或大于 2015 下面是一个例子: @XmlRootElement(name = "customer") public class Customer { @XmlElement @Min(2015) private int year; …..}现在让我们运行这个程序并发布一些数据。 要运行,...
jaxb-有效载荷-poc 概念证明,用于解决带有外部名称空间的XmlAnyElement,没有XmlRootElement和非JAXB可序列化对象的Java objetcs的问题 其作品 @franciscophilip
XML .............................................................................................................................................. 51 SOAP Transport Protocol .............................