栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

JAXB使用fractionDigits为BigDecimal编组

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

JAXB使用fractionDigits为BigDecimal编组

您将需要使用

XmlAdapter
此用例。下面是一个示例绑定文件,可以帮助您生成它们。逻辑将包含在一个
DecimalFormatter
类中,该类包含用于所有不同所需格式的方法。

<jxb:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema"    xmlns:jxb="http://java.sun.com/xml/ns/jaxb" version="2.1">    <jxb:bindings schemaLocation="schema.xsd">        <jxb:bindings node="//xs:element[@name='amount']"> <jxb:property>     <jxb:baseType>         <jxb:javaType name="java.math.BigDecimal"  parseMethod="org.example.DecimalFormatter.parseDecimal"  printMethod="org.example.DecimalFormatter.printDecimal_2Places" />     </jxb:baseType> </jxb:property>        </jxb:bindings>        <jxb:bindings node="//xs:element[@name='rate']"> <jxb:property>     <jxb:baseType>         <jxb:javaType name="java.math.BigDecimal"  parseMethod="org.example.DecimalFormatter.parseDecimal"  printMethod="org.example.DecimalFormatter.printDecimal_5Places" />     </jxb:baseType> </jxb:property>        </jxb:bindings>    </jxb:bindings></jxb:bindings>

想要查询更多的信息

  • http://blog.bdoughan.com/2011/08/xml-schema-to-java-generating.html


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/470243.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号