简体   繁体   English

Struts 1.2验证框架:用于验证的单独类

[英]Struts 1.2 validation framework: a separate class for validations

I want to validate user inputs. 我想验证用户输入。 Struts 1.2 provides a validation framework itself. Struts 1.2本身提供了一个验证框架。 But its validation is not enough for me. 但是它的验证对我来说还不够。 Also I don't like to put my validation (because it may have more codes and logic) into the Form class and need to keep separately from Action class's business logic and Form class. 另外,我不喜欢将验证(因为它可能具有更多的代码和逻辑)放入Form类,并且需要与Action类的业务逻辑和Form类分开保存。 Is there any way to use a separate validate class in Struts 1.2 ? 有没有办法在Struts 1.2中使用单独的验证类? Any useful link with sample code snippets would be appreciated. 带有示例代码段的任何有用链接将不胜感激。

Struts uses Commons Validator . Struts使用Commons Validator You can use its validators in your code where you want (eg your action extracts data from form bean into POJO and invokes business logic, and only then business logic uses Calendar validator to check entered dates). 您可以在所需的代码中使用其验证器 (例如,您的action数据从form bean提取到POJO中并调用业务逻辑,然后业务逻辑才使用Calendar验证器检查输入的日期)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM