有没有办法在 Apache Wicket 中加载多个应用程序属性文件?
我的 WicketApplication.properties 文件已经变得非常大,现在为了使其更具可读性,我想对不同文件中的属性进行分类。有没有一种方法可以实现这一点,并且仍然可以访问属性,就像它们都在 WicketApplication.properties 中一样?
My WicketApplication.properties file has grown very large, and now to keep it more readable I want to categorize properties in different files. Is there a way to accomplish that and still access the properties like if they were all in the WicketApplication.properties?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请参阅 org.apache.wicket.settings.IResourceSettings.addStringResourceLoader(IStringResourceLoader)。
您可以实现自己的 IStringResourceLoader,它可以从您想要的任何地方加载。
See org.apache.wicket.settings.IResourceSettings.addStringResourceLoader(IStringResourceLoader).
You can implement your own IStringResourceLoader which may load from wherever your want.
您可以使用每个页面甚至组件专用的属性文件:
AddressPicker.properties
- 特定于AddressPicker.java
组件的属性ProfilePage.properties
- 属性仅在给定页面上使用 (ProfilePage.java
)WicketApplication.properties
- 用于应用程序范围的属性 (WicketApplication.java
)Wicket,在查看时对于给定组件的属性,将按照与上述相同的顺序查找属性文件。 AFAIR Struts2 使用完全相同的技术。
请查看 Wicket 文档: https://cwiki.apache.org/WICKET /i18n-and-resource-bundles.html。
You can use property files dedicated per page or even component:
AddressPicker.properties
- properties specific to anAddressPicker.java
componenProfilePage.properties
- properties used only on a given page (ProfilePage.java
)WicketApplication.properties
- for aplication-wide properties (WicketApplication.java
)Wicket, when looking for properties for a given component, will look for the property files in the same order as above. AFAIR Struts2 uses exactly the same technic.
Please look at Wicket documentation: https://cwiki.apache.org/WICKET/i18n-and-resource-bundles.html.
作为最后的手段,您可以编写多个文件,但将它们合并到单个 WicketApplication.properties 中,作为构建过程的一部分。 Unix 有一个专门用于执行此操作的工具。
As a last resort, you could write multiple files, but merge them into a single WicketApplication.properties as part of your build process. Unix has a tool precisely for doing this.