| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2121 人关注过本帖
标题:用struts进行验证时无法进行invalid与email验证
取消只看楼主 加入收藏
初识JAVA
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2007-1-13
收藏
 问题点数:0 回复次数:0 
用struts进行验证时无法进行invalid与email验证
ApplicationResources.properties文件内容

errors.required={0} is not should be blank!
namelab=Name
errors.range={0} is not in the range {1} through {2}.
agelab=Age
errors.email={0} is an invalid e-mail address.
emailab=Email
errors.invalid={0} is invalid.
telab=Tel


validation.xml文件内容

<!DOCTYPE form-validation PUBLIC
          "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
          "http://jakarta.


<form-validation>
    <formset>
    
    <form name="regForm">
    
    <field property="uname" depends="required,mask">
    <arg0 key="namelab"/>
    <var>
    <var-name>mask</var-name>
    <var-value>[A-Za-z]</var-value>
    </var>
    </field>
    
    <field property="age" depends="required,intRange">
    <arg0 key="agelab"/>
    <arg1 name="intRange" key="${var:min}" resource="false"/>
    <arg2 name="intRange" key="${var:max}" resource="false"/>
    <var>
        <var-name>min</var-name>
        <var-value>5</var-value>
    </var>
    
    <var>
        <var-name>max</var-name>
        <var-value>150</var-value>
    </var>
    </field>
    
    <field property="email" depends="email">
    <arg0 key="emailab"/>
    </field>
    
    <field property="tel" depends="required, mask">
    <arg0 key="telab"/>
    <var>
    <var-name>mask</var-name>
    <var-value>^\d{3}(-\d{8})?$</var-value>
    </var>
    </field>
    
    </form>
    </formset>

</form-validation>


前台页面:
<%@ page language="java" pageEncoding="GB18030"%>
<%@ taglib uri="http://struts. prefix="bean"%>
<%@ taglib uri="http://struts. prefix="html"%>
 
<html>
    <head>
        <title>JSP for RegForm form</title>
    </head>
    <body>
        <html:form action="/reg">
            uname : <html:text property="uname"/><html:errors property="uname"/><br/>
            sex : <html:text property="sex"/><html:errors property="sex"/><br/>
            age : <html:text property="age"/><html:errors property="age"/><br/>
            email : <html:text property="email"/><html:errors property="email"/><br/>
            tel : <html:text property="tel"/><html:errors property="tel"/><br/>
            
            <html:submit/><html:cancel/>
        </html:form>
    </body>
</html>




错误信息:
java.lang.NoClassDefFoundError: org/apache/oro/text/perl/Perl5Util
    org.(GenericValidator.java:65)
    org.apache.struts.validator.FieldChecks.validateMask(FieldChecks.java:233)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.(ValidatorAction.java:544)
    org.(Field.java:796)
    org.(Field.java:876)
    org.(Form.java:288)
    org.(Validator.java:351)
    org.apache.struts.validator.ValidatorForm.validate(ValidatorForm.java:116)
    org.apache.struts.(ValidateActionForm.java:58)
    org.apache.struts.(AbstractValidateActionForm.java:120)
    org.apache.struts.(ActionCommandBase.java:51)
    org.(ChainBase.java:190)
    org.(LookupCommand.java:304)
    org.(ChainBase.java:190)
    org.apache.struts.(ComposableRequestProcessor.java:283)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


错误情况:能够进行required和intRange  但是email和mask验证 输入正确和错误都会显示上述错误
搜索更多相关主题的帖子: invalid struts email errors range 
2008-03-20 14:54
快速回复:用struts进行验证时无法进行invalid与email验证
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.036082 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved