Java – XmlRootElement 注解

huangapple go评论129阅读模式
英文:

Java - XmlRootElement annotation

问题

我有一个带有@XmlRootElement注释的类

@XmlRootElement
     class Point {
        int x;
        int y;
        Point(int _x, int _y) {x=_x;y=_y;}
     }

是否有一个函数可以生成类似以下的相对xml?

 <point>
   <x> 3 
   <y> 5 
 </point>

谢谢

英文:

I've a class with @XmlRootElement¸annotation

@XmlRootElement
     class Point {
        int x;
        int y;
        Point(int _x,int _y) {x=_x;y=_y;}
     }

Is there a function that produce the relative xml like?

 <point>
   <x> 3 
   <y> 5 
 </point>

Thanks

答案1

得分: 1

没有一个 'function' 将您的 Java 类与 XML 绑定在一起。在 Java SE 中,是 JAXB API 根据使用 @XmlRootElement 注解进行标注的 Java 类生成 XML。请阅读详细信息 这里

英文:

There is no 'function' that binds your java class with an XML. It is the JAXB API in Java SE that generates XML out of the java class annotated with @XmlRootElement annotation. Please read the details here.

huangapple
  • 本文由 发表于 2020年4月9日 21:01:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/61121787.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定