<?xmlversion="1.0"encoding="UTF-8"?> <!DOCTYPEvalidatorsPUBLIC "-//ApacheStruts//XWorkValidator1.0.2//EN" "http://struts.apache.org/dtds/xwork-validator-1.0.2.dtd"> <validators> <fieldname="username"> <field-validatortype="requiredstring"> <message>用户名不能为空</message> </field-validator> <field-validatortype="stringlength"> <paramname="minLength">2</param> <message>用户名长度不能少于2位</message> </field-validator> </field> <fieldname="password"> <field-validatortype="requiredstring"> <message>密码不能为空</message> </field-validator> <field-validatortype="stringlength"> <paramname="minLength">2</param> <message>密码长度不能少于2位</message> </field-validator> </field> <fieldname="repassword"> <field-validatortype="requiredstring"> <message>重复密码不能为空</message> </field-validator> <field-validatortype="fieldexpression"> <paramname="expression"><![CDATA[(password==repassword)]]></param> <message>两次密码不一至</message> </field-validator> </field> <fieldname="email"> <field-validatortype="requiredstring"> <message>邮箱不能为空</message> </field-validator> <field-validatortype="email"> <message>邮箱格式不正确</message> </field-validator> </field> </validators>
有时候会出现Method public java.util.List org.apache.-------------------省略
原因:想要客户端校验起作用,必须先进入Struts2核心Filter,直接进入JSP是不行的。
所以在struts2上加上:
<actionname="*"> <result>/WEB-INF/content/{1}.jsp</result> </action>
在外部写个主页什么的:类似下面这个JSP
<s:formaction="Register"> <s:submitvalue="注册"/> </s:form> <s:formaction="Login"> <s:submitvalue="登录"/> </s:form>原文链接:https://www.f2er.com/xml/298579.html