问题:
加上<html:javascript formName="loginform"/>标签
就出错,去掉标签又正常,
ValidatorResources not found in application scope under key "org.apache.commons.validator.VALIDATOR_RESOURCES"
struts-config-login.xml配置文件中配置如下:
<form-bean name="loginform" type="login.LoginForm"/>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
<set-property property="stopOnFirstError" value="true"/>
</plug-in>
validation.xml中配置如下:
<form name="loginform">
<field property="username" depends="required">
<msg name="required" key="error.username.null"/>
</field>
<field property="password" depends="required">
<msg name="required" key="error.password.null"/>
</field>
</form>
自动生成客户端验证代码的标签:
<html:javascript formName="loginform" />
onsubmit事件:
onsubmit="return validateLoginform(this);"
------解决方案--------------------------------------------------------
帮顶
------解决方案--------------------------------------------------------
不喜欢用Struts的标签,都是直接用jstl。
帮顶吧
------解决方案--------------------------------------------------------
不好意思,我不擅长xml 但是我估计是不是你调了表单,但是没有调用好
------解决方案--------------------------------------------------------
顶,,,
------解决方案--------------------------------------------------------
不懂,UP
------解决方案--------------------------------------------------------
xml写我不是太懂,不过我觉得错误是说:应用程序没有找到与<html:javascript formName="loginform"/> 关联的javascript验证代码
也就是说可能是你的
- Java code
validation.xml中配置如下: <form name="loginform"> <field property="username" depends="required"> <msg name="required" key="error.username.null"/> </field> <field property="password" depends="required"> <msg name="required" key="error.password.null"/> </field> </form>
------解决方案--------------------------------------------------------
学习,接分!
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
位置写错了 ??
------解决方案--------------------------------------------------------
<html:javascript formName="loginform" dynamicJavascript="true" staticJavascript="true"/>
再给你个参考
- XML code
<?xml version="1.0" encoding="ISO-8859-1" ?><!DOCTYPE form-validation PUBLIC "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN" "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd"><form-validation><!-- This is a minimal Validator form file with a couple of examples.--> <global> <!-- An example global constant <constant> <constant-name>postalCode</constant-name> <constant-value>^\d{5}\d*$</constant-value> </constant> end example--> </global> <formset> <!-- An example form --> <form name="logonForm"> <field property="username" depends="required"> <arg key="logonForm.username"/> </field> <field property="password" depends="required,mask"> <arg key="logonForm.password"/> <var> <var-name>mask</var-name> <var-value>^[0-9a-zA-Z]*$</var-value> </var> </field> </form> </formset> <!-- An example formset for another locale --> <formset language="fr"> <constant> <constant-name>postalCode</constant-name> <constant-value>^[0-9a-zA-Z]*$</constant-value> </constant> <!-- An example form --> <form name="logonForm"> <field property="username" depends="required"> <arg key="logonForm.username"/> </field> <field property="password" depends="required,mask"> <arg key="logonForm.password"/> <var> <var-name>mask</var-name> <var-value>^[0-9a-zA-Z]*$</var-value> </var> </field> </form> </formset></form-validation>