为什么我们必须指定“methodParams” 在struts验证插件中?
我查了《Jakarta Struts Live》一书中的验证器源代码和用户定义规则的示例。 当人们在 validator-rules.xml 中定义验证器规则时,以下“methodParams”声明似乎是唯一的选择:
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
好吧,我的问题是,如果这是唯一的可能性,为什么我们还要指定它呢? 或者,如果此声明不是唯一的选择,请给我提供一个示例。
谢谢。
I have checked the validator source code and the examples of user-defined rule in the book "Jakarta Struts Live." When people define validator rules in validator-rules.xml, the following declaration for "methodParams" seems to be the only choice:
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
Okay, my question is that if this is the only possibility, why do we bother to specify it? Or please provide me with an example if this declaration is not the only choice.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请看一下这个链接:
http://struts.apache.org/1.1/userGuide/dev_validator.html
它说:
看来“methodParams”可以是列出的类型的任意组合,并且 Strurs Validator Plugin 会将实例相应地注入到验证函数调用中。
“methodParams”可以更改。
Please take a look at this link:
http://struts.apache.org/1.1/userGuide/dev_validator.html
It says:
It seems that "methodParams" can be any combination of the listed types, and Strurs Validator Plugin will inject the instances into the validation function call accordingly.
"methodParams" can be changed.