How to configure JAXB so it trims whitespaces by default

前端 未结 3 2086
遥遥无期
遥遥无期 2021-01-04 04:31

I would like to configure JAXB so that it trims whitespaces on all string fields

I saw the following answer : How to configure JAXB so it trims whitespaces when unma

3条回答
  •  别那么骄傲
    2021-01-04 04:59

    It might be worth mentioning, that in addition to writing an XmlAdapter, which performs the trimming, you can configure XJC to actually use this adapter in generated code. An example of how to do it:

    
        
    
    

    The above example uses the XmlAdapter given in Sahil's answer

提交回复
热议问题