在Xwork中,不能将-validation.xml放置在与相应Action类相同的包中之外的其他位置
我正在使用 xwork 进行服务端 POJO 验证。 我正在执行一个操作,例如 ValidationAction.java,并且我有一个名为的相应 xml 文件 ValidationAction-validation.xml,其中有字段的验证规则。
根据我能找到的规范和文档,我知道这个 xml 文件应该与 ValidationAction.java 文件保存在同一个包中。 但是,由于我确实有很多 java 文件需要进行验证,因此也有很多相应的 xml 文件,所以我不想将它们放在同一个包中。
我想要一个不同的文件夹/包来存放 xml 文件。
这有什么办法吗?
谢谢和问候。
I'm working on service side POJO validation using xwork.
I am having an action, say ValidationAction.java, and I have a corresponding xml file named
ValidationAction-validation.xml, which has validation rules on fields.
As per the specification and the documentation I could find, I understand that this xml file should be kept in the same package as the ValidationAction.java file.
However, since I do have many java files to go through validation, and hence many corresponding xml files, I don't want to put them together in the same package.
I want to have a different folder/package for the xml files.
Is there any way out for this?
Thanks and regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将它们放在同一个包中,因为这就是 xwork 验证器的工作方式。如果您不想执行所有这些操作,则可以实现 Validatable 接口:在操作上定义一个自定义
validate()
方法,该方法将在执行操作之前调用。例子:
You are putting them in the same pacage because that's how xwork validators work. What you can do, if you don't want to do all this, is implement the Validatable interface: define a custom
validate()
method on your action which will be called before the Action will be executed.Example: