jaxb

Setting CharacterEscapeHandler variable on a Marshaller doesn't work as expected in CXF

两盒软妹~` 提交于 2021-02-19 04:14:38
问题 I'm using Apache CXF to implement some WebServices at server side. I have to implement a WebService that returns a string (Holder) with some values separated by tab character. Apache CXF encodes character tab as a tab, but our client (that can not be change...) doesn't accept it and only read tabs encoded as . So I tried to simply make a replaceAll on the string to change \t for , but an escapeHandler on Marshaller changes it to 	 . Then I tried to create a customCharacterEscapeHandler

SpringBoot @RequestBody 报错 ('application/x-www-form-urlencoded;charset=UTF-8' not supported)

こ雲淡風輕ζ 提交于 2021-02-18 01:54:52
第一种:转 https://blog.csdn.net/chenfei2341/article/details/83652586 在Spring boot 中使用 @RequestBody 会报错,提示错误 Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported ,代码如下: @RequestMapping(value = "/act/service/model/{modelId}/save", method = RequestMethod.POST) public void saveModel(@PathVariable String modelId, @RequestBody MultiValueMap<String, String> values) { // 具体代码 } 这个在传统 spring MVC 中是有效的,但是在 Spring boot 中会报错。 传统是 Spring MVC 有效,是因为有 <mvc:annotation-driven> 注解,查资料,<mvc:annotation-driven> 注解配置了如下的内容 spring 3.1 版本: <!-- 注解请求映射 --> <bean class ="org.springframework.web

One domain model, multiple json views

冷暖自知 提交于 2021-02-18 00:14:07
问题 We have a set of domain classes which are serialized to json via jackson using jersey services. We are currently annotating the classes with JAXB (although we're not tied to that). This works fine. But we want to offer different serializations of the classes for different use cases. Web site Mobile apps Admin tool Public API In each of these cases there are different fields which we may or may not want included in the json view. For example, the admin tool might need some parameters for

merge multiple files with JAXB

帅比萌擦擦* 提交于 2021-02-17 05:55:09
问题 It's the first time I'm using stackoverflow and I don't speak English perfectly so be nice please. I'm using Jaxb in append mode like that for (Document330 document : documents){ JAXBContext jContext = JAXBContext.newInstance(Document330Xml.class); Marshaller m = jContext.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.marshal(document, fos); } And I have an output file like that: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <DOCUMENT> <MAILING>

How to convert CSV to XML in Java using JAXB

陌路散爱 提交于 2021-02-11 15:12:41
问题 I am trying to consume a CSV file using apache camel and convert each row to XML and publish each xml to solace topic. XML format is complex and I am not sure how to create such a complex XML in Java. CSV contains employee payload fields. Other part of XML including header, auditRecords and ancillaryData are hardcoded/static data(timestamp can be current date). How to convert CSV to XML in Java using JAXB? <canonMessage xmlns="http://www.test.com/canon/v1"> <header> <metadata> <domain> <name

How to convert CSV to XML in Java using JAXB

一世执手 提交于 2021-02-11 15:11:26
问题 I am trying to consume a CSV file using apache camel and convert each row to XML and publish each xml to solace topic. XML format is complex and I am not sure how to create such a complex XML in Java. CSV contains employee payload fields. Other part of XML including header, auditRecords and ancillaryData are hardcoded/static data(timestamp can be current date). How to convert CSV to XML in Java using JAXB? <canonMessage xmlns="http://www.test.com/canon/v1"> <header> <metadata> <domain> <name

JAXB / Java 11 / Tomcat - DataHandler No default constructor

百般思念 提交于 2021-02-11 14:23:14
问题 I have some trouble with JAXB, i found out that it exists many implementations of it, i used JBoss and the code worked well (Metro JAXB), now with tomcat and com.sun.xml.bind.. it doesn't, it cannot convert the Base64 encoded String into a DataHandler. Now i recompiled it again and i'm trying if the @XMLAttachmentRef would solve my trouble. [com.sun.xml.bind.v2.ClassFactory] No default constructor found on class javax.activation.DataHandler java.lang.NoSuchMethodException: javax.activation

How to generate xml file with an existing dtd for sample of data using Java

旧城冷巷雨未停 提交于 2021-02-11 12:29:36
问题 I have some data stored in : HashMap<Position, Double> listOfPoints = new HashMap<>(); Where key contains pair (x,y). I have defined also my dtd file called generated.dtd which contains my structure : <!ELEMENT table (point*,id,position,x,y,value)> <!ELEMENT point (id,position,value)> <!ELEMENT id (ID)> <!ELEMENT position (x,y)> <!ELEMENT value (#PCDATA)> <!ELEMENT x (#PCDATA)> <!ELEMENT y (#PCDATA)> Using that file and sample of data stored in listOfPoints , I would like to generate an xml

How to map xml fields without parent tag to java list?

一笑奈何 提交于 2021-02-11 06:17:51
问题 I have following xml response from web service which need to map to java class. <api1Response> <timeStamp>06/24/2016 07:45:10</timeStamp> <ippProjectName>xyz</ippProjectName> <project> <projectId>1</projectId> <projectName>ABC</projectName> <dataDate>06/06/2016</dataDate> </project> <project> <projectId>2</projectId> <projectName>PQR</projectName> <dataDate>06/06/2016</dataDate> </project> </api1Response> I have mapping class like class api1Response{ String timeStamp; String ippProjectName; /

How to map xml fields without parent tag to java list?

梦想与她 提交于 2021-02-11 06:17:12
问题 I have following xml response from web service which need to map to java class. <api1Response> <timeStamp>06/24/2016 07:45:10</timeStamp> <ippProjectName>xyz</ippProjectName> <project> <projectId>1</projectId> <projectName>ABC</projectName> <dataDate>06/06/2016</dataDate> </project> <project> <projectId>2</projectId> <projectName>PQR</projectName> <dataDate>06/06/2016</dataDate> </project> </api1Response> I have mapping class like class api1Response{ String timeStamp; String ippProjectName; /