struts动态表单验证! 配置VALIDATOR?能否讲详细点.偶是初学.那在成功页怎么写呢. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1.FormBean中validate方法public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if(userName == null || userName.length() < 1){ errors.add("userName",new ActionMessage("userName.error")); } if(password == null || password.length() < 1){ errors.add("password",new ActionMessage("password.error")); } if(code == null || code.length() < 1){ errors.add("code",new ActionMessage("code.error")); } return errors;}2.需要验证的页<html:form action="/login">用户名:<html:text property="userName" maxlength="20" size="13"/> <html:errors property="userName"/> ---property="userName" 对应上面配置的userName密 码:<html:password property="password" maxlength="20" size="13"/> <html:errors property="password"/> ---property="password" 对应上面配置的password请输入验证码: <html:text property="code" maxlength="4" size="5"/> <html:errors property="code"/> ---property="code" 对应上面配置的code 楼上的仁兄.好像是静态验证.我需要的是动态验证.没有loginForm的.没有validate方法 让loginForm继承一个org.apache.struts.validator.DynaValidatorActionForm就行了吧 Hibernate启动后不能自动建表 急,扑克牌的算法 做网站流量统计的问题 挑战高手真正水平的问题 hibernate的主键设置问题!急! j2ee实战网络教学课程 怎么用自己的机子作为服务器编写发送邮件的程序,请各位大侠指教!!! 想通过一个servlet传参数运行一个main函数 求指点 J2EE与支持EJB的APPServer的关系? 不用toolbox如何安装windows版本的Docker 50分求一读写一XML文件的方法【快答快结,闪电结贴】 一个AJAX的问题!急
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if(userName == null || userName.length() < 1){
errors.add("userName",new ActionMessage("userName.error"));
}
if(password == null || password.length() < 1){
errors.add("password",new ActionMessage("password.error"));
}
if(code == null || code.length() < 1){
errors.add("code",new ActionMessage("code.error"));
}
return errors;
}
2.需要验证的页
<html:form action="/login">
用户名:<html:text property="userName" maxlength="20" size="13"/>
<html:errors property="userName"/> ---property="userName"
对应上面配置的userName
密 码:<html:password property="password" maxlength="20" size="13"/>
<html:errors property="password"/> ---property="password"
对应上面配置的password
请输入验证码:
<html:text property="code" maxlength="4" size="5"/>
<html:errors property="code"/> ---property="code"
对应上面配置的code