Struts 2 では@CustomValidator
、アプリケーション全体で使用できるものを開発できます
@CustomValidator(type = "CustomerNumberValidator", fieldName = "customerNo")
検証のために、複数のフィールドを使用します@ExpressionValidator
@ExpressionValidator(expression =
"( (!''.equals(account.firstName) && (!''.equals(account.lastName) )
|| (presonalAccount == false)",
key = "validate.account.name")
式が複雑すぎて複数のフィールドで動作する必要がある場合は、OGNL を使用して静的メソッドを呼び出します。静的メソッドは検証を行い、boolean
たとえば
@ExpressionValidator(expression = "@foo.bar.CalendarUtil@compareDates(fromDate,toDate)", key = "validate.date.before")
上記は、カスタム式バリデーターの一部です。
そして@foo.bar.CalendarUtil@compareDates
、アプリケーション全体で使用して、この検証を行います。
カスタムワイドバリデーターを使用できるようにする別のアプローチはありますか?!
Struts に追加できるカスタム式バリデーターはありますか?Action
使用する方法で呼び出すことができます@CustomValidator
か?