JAXB attributes using underscore

本小妞迷上赌 提交于 2020-07-30 07:26:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!