如何在 Struts 2 中组织大量的 action-validation.xml 文件?
在Struts-2应用程序中,有许多Action类和action-validation.xml文件 对于每个 Action 类,如何将所有这些验证 xml 文件组织到一个单独的文件中 文件夹(例如“属性文件夹”)并从那里访问验证规则。
In a Struts-2 Application, there are many Action classes and action-validation.xml files
for each Action classes how can I organize all these validation xml files into a single
folder such as in a "properties folder" and access validation rules from there.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这很大程度上取决于您使用的构建系统。例如,如果您使用 Maven 进行构建,则可以将validation.xml 文件放置在 src/main/resources 内的同名包中,而不是 src/main/java 中。在 Ant 中,您可能可以在任何地方进行设置,并让 Ant 将 xml 文件复制到最终 war 文件中的正确位置,尽管我不确定如何操作,因为我并没有真正使用过 Ant。
我认为关键在于,在最终打包的 war 中,xml 文件需要与该操作的类文件位于同一位置。它们在构建时间之前的位置并不那么重要。
A lot of it depends on what build system you are using. If you are using Maven to build, for example, you can place the validation.xml files in an identically named package inside of src/main/resources instead of src/main/java. In Ant, you could probably set it up anywhere and have Ant copy the xml files to the correct place in the final war file, though I am not sure how, not really having used Ant much.
I think the key thing is that in the final packaged war, the xml files need to be in the same place as the class files for that action. Where they are before build time doesn't so much matter.