In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you about the pit encountered in JAXB, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
1. When you use JAXB to convert xml to java objects, simply by annotating @ XmlRootElement (namespace= "xxxxxx"), there are two problems with the life namespace on the root class:
The scope of the namespace acts only on the root tag, not recursively on all subordinate tags, resulting in the loss of all child attributes using the @ XmlElement flag.
The named namespace produces a prefix in the shape of nsN.
Solution: configure the package-info.java file as follows, such as notes:
/ * package-info.java * under the same package path as the entity * / @ XmlSchema (/ / set the namespace here in order to use the following @ xmlnx renaming prefix namespace = "http://www.omg.org/spec/BPMN/20100524/MODEL", / / set the scope of application of the namespace QUALIFIED is applied to all tags elementFormDefault = XmlNsForm.QUALIFIED, xmlns = {@ XmlNs (prefix = "activiti", namespaceURI = "http://activiti.org/bpmn"), @ XmlNs (prefix =" bpmndi ", namespaceURI =" http://www.omg.org/spec/BPMN/20100524/DI"), / / rename prefix @ XmlNs (prefix = "" NamespaceURI = "http://www.omg.org/spec/BPMN/20100524/MODEL")})package com.bpmn Import javax.xml.bind.annotation.XmlNs;import javax.xml.bind.annotation.XmlNsForm;import javax.xml.bind.annotation.XmlSchema
two。 To achieve the mapping of xml and java objects, you need to annotate in one of two ways:
Method 1: add @ XmlAttribute or @ XmlElement to the @ XmlAccessorType annotation and attribute declaration
Method 2: use @ XmlAttribute or @ XmlElement directly on get or set methods
The above are the pits encountered in JAXB, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.