此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【net_xmrc】截止到2008-07-29 16:22:10的历史汇总数据(不包括此帖):
发帖的总数量:6                        发帖的总分数:90                       每贴平均分数:15                       
回帖的总数量:5                        得分贴总数量:0                        回帖的得分率:0%                       
结贴的总数量:6                        结贴的总分数:90                       
无满意结贴数:2                        无满意结贴分:20                       
未结的帖子数:0                        未结的总分数:0                        
结贴的百分比:100.00%               结分的百分比:100.00%                  
无满意结贴率:33.33 %               无满意结分率:22.22 %                  
敬礼!

解决方案 »

  1.   

    我把DEMO的程序贴出来吧
    //重写父类的validate方法,用来验证客户端来的数据
    public ActionErrors validate(){
    ActionErrors errors = new ActionErrors();

    if (userName == null || userName.equals("")) {
               return errors;
    // errors.add(ActionErrors.GLOBAL_MESSAGE, new ActionError("loginform.error.username"));  }    if (userPwd == null || userPwd.equals("")) {   //errors.add(ActionErrors.GLOBAL_MESSAGE,    //new ActionError("loginform.error.password"));      }         return errors;

    }
      

  2.   

    //ActionForm
    public ActionErrors validate(ActionMapping mapping,
    HttpServletRequest request) {
    //一个用来装在验证过程中出现的错误的容器
    ActionErrors errors = new ActionErrors();
    try {
    if (pwd.length()<6){
    //如果密码长度不够,往errors中放入一个错误
                                         //add()方法的第一个参数给的是jsp页面里的错误标识,><html:errors property="pwderror"/>
    errors.add("pwderror",new ActionMessage("pwd.length.error"));
    }

    if (email.indexOf("@")==-1){
    errors.add("emailformaterror",new ActionMessage("invail.eamil.format"));
    }

    } catch (Exception e) {
    e.printStackTrace();
    }
    return errors;//jsp页面
    <%@ page language="java" pageEncoding="GB18030"%>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%> 
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
     
    <html> 
    <head>
    <title>JSP for RegForm form</title>
    </head>
    <body>
    <html:form action="/reg">
    email : <html:text property="email"/><html:errors property="emailformaterror"/><br/>
    pwd : <html:text property="pwd"/><html:errors property="pwderror"/><br/>
    <html:submit/><html:cancel/>
    </html:form>
    </body>
    </html>
      

  3.   

    ActionErrors 它就是装错误信息的容器。
    它里面的add()方法存放的错误信息是以键值对的形式。