通过 HTTP 加载 ResourceBundle?
我需要从我们的 CMS 加载文本标签。内容以标准属性文件格式公开。 CMS 作为一种 RESTful Web 服务提供商运行,而不是推送文件,因此我需要按需提取属性文件。我天真地希望,如果我创建了一个 ReloadableResourceBundleMessageSource 并将基本名称设置为文件的 URL 减去区域设置参数,那么这会像魔术一样起作用,但显然事实并非如此。任何人都可以建议一种方法吗? Spring 中是否有开箱即用的解决方案,或者是否有一些我需要扩展的类?
I have a requirement to load text labels from our CMS. The content is exposed in standard properties file format. The CMS operates as a sort of RESTful web service provider as opposed to pushing files, so I would need to pull properties files on demand. I was naively hoping that if I created a ReloadableResourceBundleMessageSource and set the basename to the URL of the file minus the locale parameter, that this would work like magic, but evidently it doesn't. Can anyone suggest an approach to this? Is there an out-of-the-box solution in Spring or is there some class that I would need to extend?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以,斯卡夫曼的评论是正确的。我的 Web 服务只是期望区域设置作为 GET 参数 (locale=en_US),但正在获取文件后缀(即 locale=_en_US.properties)。因此,从参数中删除额外的内容就很简单,而且实际上工作得很好。
So, skaffman's comment was correct. My web service was just expecting the locale as a GET param (locale=en_US), but was getting a file suffix (ie, locale=_en_US.properties). So, it was as simple matter of stripping the extra stuff from the param and it actually works fine.