简体   繁体   中英

Java jaxb xml with generics how to prevent automatically added attributes

Hello I want the following xml

<ns1:val>hello world</ns1:val>

I'm currently getting

<ns1:val type="xs:string">hello world</ns1:val>

When marshalling

    @XmlElement(name="val", namespace = "ns1")
    private ArrayList<T> value;

the marshaller is defined as follows

        var sw = new StringWriter();
        var jc = JAXBContext.newInstance(MyClass.class);
        var marshaller = jc.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.marshal(query, sw);

How can I prevent type="xs:string" from being added to the xml when using generics?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM