該 validator 表單定義了一個 validate() 方法,但沒有調用 super.validate()。
Struts Validator 使用表單的 validate() 方法,對照那些在相關校驗表單中定義的約束條件來檢測表單屬性的內容。這就意味著以下這些類具有一個 validate() 方法,該方法是校驗框架的一部分:
ValidatorForm
ValidatorActionForm
DynaValidatorForm
DynaValidatorActionForm
validate() 函數,強行實現自定義校驗邏輯,則您必須在 validate() 的實現方法中調用 super.validate()。如果不這么做,校驗框架就無法對照校驗表單來校驗表單中的內容。換言之,針對某個特定的表單,會禁用校驗框架。[1] Standards Mapping - OWASP Top 10 2004 - (OWASP 2004) A1 Unvalidated Input
[2] Standards Mapping - Security Technical Implementation Guide Version 3 - (STIG 3) APP3510 CAT I
[3] Standards Mapping - Security Technical Implementation Guide Version 3.4 - (STIG 3.4) APP3510 CAT I
[4] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 103
[5] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 - (PCI 1.2) Requirement 6.3.1.1
[6] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 - (PCI 1.1) Requirement 6.5.1
[7] T. Husted et al. Struts in Action:Building Web Applications with the Leading Java Framework Manning Publications
[8] The Struts project The Apache Foundation