Non Field Validator 사용예

여기서는 Non Field Validator에 대해서 알아 본다. Non Field Validator는 입력필드에 Validator를 붙이는 형식이 아닌 Validator이다.

Step 1

jsp page작성.

<s:actionerror />
<s:form method="POST" action="submitNonFieldValidatorsExamples" namespace="/validation">
    <s:textfield name="someText" label="Some Text" />
    <s:textfield name="someTextRetype" label="Retype Some Text" />  
    <s:textfield name="someTextRetypeAgain" label="Retype Some Text Again" />
    <s:submit label="Submit" />

Step 2

Action클래스 작성.

public class NonFieldValidatorsExampleAction extends AbstractValidationActionSupport {

    private static final long serialVersionUID = -524460368233581186L;

    private String someText;
    private String someTextRetype;
    private String someTextRetypeAgain;

    public String getSomeText() {
        return someText;
    public void setSomeText(String someText) {
        this.someText = someText;
    public String getSomeTextRetype() {
        return someTextRetype;
    public void setSomeTextRetype(String someTextRetype) {
        this.someTextRetype = someTextRetype;
    public String getSomeTextRetypeAgain() {
        return someTextRetypeAgain;
    public void setSomeTextRetypeAgain(String someTextRetypeAgain) {
        this.someTextRetypeAgain = someTextRetypeAgain;

Step 3


<validator type="expression">
<param name="expression"><![CDATA[ ( (someText == someTextRetype) && (someTextRetype == someTextRetypeAgain) ) ]]></param>
<message><![CDATA[ all three text must be exactly the same ]]></message>