I tried to use validator in my struts application and I find a problem
occurred:
The form did not validate itself and the execute method is
always called.
I active the plug-in in struts-config.xml as following:
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
and I write the validation.xml as following:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules
Configuration 1.0//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_0.dtd">
<form-validation>
<global>
<constant>
<constant-name>phone</constant-name>
<constant-value>^\(?(\d{3})\)?[-| ]?(\d{3})[-|
]?(\d{4})$</constant-value>
</constant>
<constant>
<constant-name>zip</constant-name>
<constant-value>^\d{5}\d*$</constant-value>
</constant>
</global>
<!-- ========================= Default Formset
========================= -->
<formset>
<form name="sForm">
<field property="name" depends="required">
<arg0 key="test.name"/>
</field>
</form>
</formset>
</form-validation>
I write the struts-config.xml as following for mapping
<action
attribute="sForm"
input="/form/s.jsp"
name="sForm"
path="/s"
scope="request"
type="com.eam.struts.action.SAction"
validate="true">
<forward name="success" path="/welcome.do" />
</action>
The form extends the ValidatorForm,
But it does NOT work.
Who can help me?
Thanks a lot.
--
Why Signature?