- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
[Core]2 类型格式化(Formatter)
Now consider the type conversion requirements of a typical client environment such as a web or desktopapplication. In such environments, you typically convert from String to support the client postbackprocess, as well as back to String to support the view rendering process. In addition, you often need tolocalize String values. The more general core.convert Converter SPI does not address such formattingrequirements directly. To directly address them, Spring 3 introduces a convenient Formatter SPI thatprovides a simple and robust alternative to PropertyEditors for client environments.现考虑一种典型的客户环境(如一个web应用程序或桌面应用程序)中的类型转换的需求。在这个环境中,我们通常把String转换为客户回调过程支持的类型。另外,我们也经常需要本地化String的值。而Converter SPI不能支持处理这样的格式化需求。为了能直接处理这种情况,Spring 3引进Formatter SPI来提供一个简单和健壮的替代PropertyEditors的方案。In general, use the Converter SPI when you need to implement general-purpose type conversion logic; forexample, for converting between a java.util.Date and and java.lang.Long. Use the Formatter SPI whenyoure working in a client environment, such as a web application, and need to parse and print localizedfield values. The ConversionService provides a unified type conversion API for both SPIs.一般来说,当需要实现普通目的的转换逻辑时(例如在Date和Long之间转换)可以使用Converter SPI。当工作在客户环境中(如web应用还需要解析和打印本的字段的值)可以使用Formatter SPI。ConversionService为这两种SPI提供统一的类型转换API。A、Formatterorg.springframework.format.FormatterTpublic interface FormatterT extends PrinterT, ParserTFormats objects of type T. A Formatter is both a Printer and a Parser for an object type.格式化T类型的对象。一个Formatter实现了Printer和Parser接口。A.1、Parserorg.springframework.format.ParserTpublic interface ParserTT - the type of object this Parser producesT-这个解析器产生的T类型的对象Parses text strings to produce instances of T.把字符串解析为T类型的实例。方法Tparse(String text, Locale locale) A.2、Printerorg.springframework.format.PrinterTpublic interface PrinterTT - the type of object this Printer printsT -这个Printer显示对象的类型Prints objects of type T for display.把T类型转换为String。方法Stringprint(T object, Locale locale)范例2:pub
您可能关注的文档
- PVDF树脂在太阳能电池模组用背板上的应用.doc
- office2013默认新建2003.doc
- 鹿茸、鹿心和鹿血中IGF-Ⅰ的含量检测.docx
- Vosue红天堂鸟arome芳香味.docx
- FPGA中为什么要把NCEO设置为普通的IO口.doc
- Unit_7How_do_you_make_a_banana_milk_shake_教案.doc
- ArcEngine 面积测量实现.docx
- 8000_6 (商业信函用语)正文部分.doc
- 24.不干胶薄膜质量要求.doc
- 非线性编辑实验报告4-转场特效.doc
- Oracle 10g RAC OCR 和 VotingDisk 的备份与恢复.doc
- 听力简写符号(雅思,托福,口译,翻译必备).docx
- 右键菜单新建中添加word、excel、ppt等项目(包括03版和07版).docx
- JBoss集群搭建手册.docx
- Win7右键没有新建Word、excel、powerpoint解决方案.docx
- Oracle10g RAC环境OCR的VOTING DISK备份管理.doc
- RegularExpressionValidator控件中正则表达式用法.doc
- 第六届外语文化艺术节初中专场主持人台词.doc
- 2013美国就业前景最好的州:亚利桑那.doc
- Cisco产品线.doc
最近下载
- 2024-2025学年第一学期 青岛版小学信息科技四年级上册 第一单元 信息科技基础 课时学历案 .pdf VIP
- 外研版(2025)必修第一册Unit 1 A New Start Developing ideas Writing 课件(13张ppt)(含音频+视频).pptx VIP
- 2024-2025学年第一学期 青岛版小学信息科技四年级上册 第二单元 反馈与优化 课时学历案 .docx VIP
- 高压试验危险点分析及控制措施.doc VIP
- 2024-2025学年第一学期 青岛版小学信息科技五年级上册 第二单元 在线生活(学历案设计) 0001.pdf VIP
- 21 CFR 210&211 cGMP中英对照版.doc VIP
- 网约车从业资格证考试题库及答案大全.doc VIP
- q cpu用户手册功能解说程序基础篇.pdf
- 做账实操-货代物流公司成本核算.pdf
- 成人的情绪管理课件.pptx VIP
文档评论(0)