Structs 关于JSP业面CHECK的问题 common文件有一些写好的 校验,应用就可以了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用页面javascrip配合XML效验ringName属性不能为空,并且不能超过50个字符1.WebRoot\WEB-INF下添加validation.xml,validator-rules.xml2.struts-config.xml中加入<plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" /></plug-in>3.WEB-INF/validation.xml中加入 <form-validation> <formset> <form name="ringForm"> <field property="ringName" depends="required,maxlength"> <arg0 key="Ring.ringName" /> <arg1 name="maxlength" key="${var:maxlength}" resource="false" /> <var> <var-name>maxlength</var-name> <var-value>50</var-value> </var> </field> </form> </formset> </form-validation>4.最后再jsp文件中添加<html:javascript formName="ringForm"/>function validateSave(){ var form = document.forms[0]; if(validateRingForm(document.forms[0])){ document.forms[0].submit(); }} to junkie80(铁孩儿) :我按你的方法做了,可是打开JSP时出错,我的JSP如下:<body bgcolor="white"><h3></h3><p>Struts+Dao Sample Application</p><html:javascript formName="LoginForm"/>function validateSave(){ var form = document.forms[0]; if(validateLoginForm(document.forms[0])){ document.forms[0].submit(); }}<html:errors /><html:form action="/LoginProcess" > <table border="0"> <tr> <th>userid</th> <td><html:text property="userId" /></td> </tr> <tr> <th>password</th> <td><html:password property="password" /></td> </tr> <tr> <td><html:submit value="sbmit"/></td> <td><html:reset value="reset"/></td> </tr> </table> <i>test sample</i></html:form></body>不知是否是写错了,还是在validation.xml,validator-rules.xml这两个文件中还要配置其它什么信息? 你formbean需要继承validaterform。 有兄弟要手机号码吗!看看手机号码咋样! jsp调用javabean产生的奇怪错误 blob 存储图片后怎么能把一组图片拿出来发送到浏览器上显示 网上都是千篇一律 看咱们有没有能人 求助!!!急,谁知道这个是什么问题? 高手请进,在EJB的home接口中为什么要使用java.io.Serializable? 在线等!图文排版解决方案! 菜鸟小问题! 请教——通过C++Builder或Delphi访问EJB能否返回类对象? 数据库取值动态插入WORD文档. 求助 hibernate HQL Query对象 导包 请帮忙推荐几个函数库的网站 各位谁知道这个到底是为什么啊?郁闷好几天了!
1.WebRoot\WEB-INF下添加validation.xml,validator-rules.xml
2.struts-config.xml中加入
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
</plug-in>
3.WEB-INF/validation.xml中加入
<form-validation>
<formset>
<form name="ringForm">
<field property="ringName" depends="required,maxlength">
<arg0 key="Ring.ringName" />
<arg1 name="maxlength" key="${var:maxlength}"
resource="false" />
<var>
<var-name>maxlength</var-name>
<var-value>50</var-value>
</var>
</field>
</form>
</formset>
</form-validation>
4.最后再jsp文件中添加
<html:javascript formName="ringForm"/>function validateSave(){
var form = document.forms[0];
if(validateRingForm(document.forms[0])){
document.forms[0].submit();
}
}
我按你的方法做了,可是打开JSP时出错,
我的JSP如下:
<body bgcolor="white"><h3></h3>
<p>Struts+Dao Sample Application</p>
<html:javascript formName="LoginForm"/>
function validateSave(){
var form = document.forms[0];
if(validateLoginForm(document.forms[0])){
document.forms[0].submit();
}
}
<html:errors />
<html:form action="/LoginProcess" >
<table border="0">
<tr>
<th>userid</th>
<td><html:text property="userId" /></td>
</tr>
<tr>
<th>password</th>
<td><html:password property="password" /></td>
</tr>
<tr>
<td><html:submit value="sbmit"/></td>
<td><html:reset value="reset"/></td>
</tr>
</table>
<i>test sample</i>
</html:form>
</body>
不知是否是写错了,还是在validation.xml,validator-rules.xml这两个文件中还要配置其它什么信息?