Dozer:CustomerConverter具有国际化/本地化意识,如何实现?
我还没有使用过 Dozer,但 Dozer 看起来很有前途。我已经阅读了大量文档,但我仍然完全不知道需要做什么来编写本地化/国际化感知的 CustomConverter:
示例:我想根据区域设置将字符串值转换为日期。我有一个 DTO(没有区域设置),当然还有区域设置(来自 ServletContainer=>Browser)。如何将区域设置注入 CustomConverter 或映射进程,以便我可以将其用于特定于区域设置的转换并访问区域设置对象? (更一般地说,如何一般注入某种我可以在转换器中使用的“上下文对象”......
我将非常感谢您说明如何实现这一点的非常粗略的步骤/如果这是可能的。 非常感谢!
I have not yet used Dozer, but Dozer seems promising. I have read quite a lot of the documentation but I am still completely clueless about what I need to do to write a CustomConverter that is localization/internationalization aware:
Example: I want to convert String values to Dates, depending on the locale. I have a DTO (without the locale) and of course the locale (from the ServletContainer=>Browser). How am I able to inject the locale to the CustomConverter or the mapping process, so that I can use it for a locale specific Conversion and I get access to the locale object? (And more generically, how to in general inject some kind of "contextobject" that i can use in the converter...
I would be very thankfull for stating the very rough steps how this would be implemented/if this is possible.
Thank you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能会考虑使用自定义 bean 工厂来创建并使用区域设置参数初始化 dto。
http://dozer.sourceforge.net/documentation/custombeanfactories.html
http://dozer.sourceforge.net/documentation/customCreateMethod.html
You might consider using a custom bean factory to create and initialize the dto with a locale parameter.
http://dozer.sourceforge.net/documentation/custombeanfactories.html
http://dozer.sourceforge.net/documentation/customCreateMethod.html