问题
I working on JAXB to using java object I am creating xml.But im using javaclass fields Like
qpack_id as attrubute it creating in xml file like qpackId
so how can i use _(underscore) in jaxB please guide me.
xml file should create bellow attibute
<qpack " qpack_id="MB0046_SET4" qpack_name="MB0046">
</qpack>
回答1:
Starting from Java Classes
You can use the XmlAttribute
annotation to specify a name.
@XmlAttribute(name="qpack_name")
public String getQPackName() {
return qPackName;
}
Starting from XML Schema
If you are talking about generating Java classes from an XML schema and preserving the _
character in the Java properties names see the answer below for a complete example:
- How to disable Java Naming Conventions in xjc?
来源:https://stackoverflow.com/questions/13891942/jaxb-attributes-using-underscore