Struts 1.2 验证问题
我正在验证我的登录表单。我创建了一个validation.xml,在struts-config.xml中添加了插件,创建了ApplicationResource.properties文件等。我已经完成了验证框架工作的所有必要操作,我的应用程序也运行没有错误,但它没有验证数据。我已经复查过很多次了。请任何人告诉我应该在哪里检查可能的错误。
谢谢
I am validating my login form. I have created a validation.xml, added the plugin in struts-config.xml, created ApplicationResource.properties file etc. I have done all the necessary things for validation frame work, my application is also running without errors but it is not validating the data. I have rechecked many times. Please anyone tell me where should I check for probable errors.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果正如您所说,应用程序运行时没有错误,并且您的数据未经过验证,那么我认为您的应用程序没有选择验证器插件。如果您的登录表单不是扩展
ValidatorForm
而是扩展您的普通ActionForm
,则可能会发生这种情况。您是否正在扩展ValidatorForm
?根据 Struts 验证器指南重新检查您的代码。即使您已经这样做了,您仍然可能会错过或误解一些东西。
让同事或朋友看一下。具有新鲜干净视角的人可能会注意到你因为长时间盯着自己的代码而错过的东西。
如果不可能,您可以随时删除所有内容(即:将当前解决方案保存在某处,然后从源代码管理中获取干净的副本)并从头开始。如果它有效,您可以与从初始解决方案中保存的内容进行比较并找出差异。
If as you say, the application is running without errors and your data is not validated, then I think that the validator plugin isn't picked up by your application. That could occur if your login form is not extending
ValidatorForm
but your plainActionForm
. Are you extendingValidatorForm
?Recheck your code against a Struts validator guide. Even if you already did that, there is still something you might have missed or misunderstood.
Have a colleague or friend look at it. Someone with a fresh clean perspective might notice something you missed because you stared to long at your own code.
If that is not possible you can always delete everything (that is to be read as: save current solution somewhere then get a clean copy from source control) and start from scratch. If then it works, you can compare with what you saved from your initial solution and spot the difference.