You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by 白鹏 <bi...@gmail.com> on 2009/04/13 06:06:34 UTC
[Help] I cannot make the Validation in struts 2.0 works.....
Hello , the main codes in jsp is:
*log.jsp *
<s:form method="post" action="/login/login.action" *validation="true"* >
用户名:<s:textfield name="userName" /> <br>
密码:<s:password name="passwd" /> <br>
验证码: <s:textfield name="vercode" /><br>
验证码如图:<img src="authImg.do" id="authImg"/> <br>
看不清? <a href="log.jsp" onclick="refresh()">单击此处刷新</a>
<input type="hidden" name="redirectUrl" value="<s:property
value="redirectUrl"/>"/>
<input type="submit" value="确定">
<input type="reset" value="重置">
</s:form>
*The returned html file contains:*
<script type="text/javascript"
src="/LearnDataProject/struts/xhtml/validation.js"></script>
<script type="text/javascript"
src="/LearnDataProject/struts/utils.js"></script>
but *There isn't the folder 'struts' in my App /LearnDataProject .*
**
*Why this happens??? *
*Thanks for your help! *
Re: [Help] I cannot make the Validation in struts 2.0 works.....
Posted by Dave Newton <ne...@yahoo.com>.
白鹏 wrote:
> *The returned html file contains:*
>
> <script type="text/javascript"
> src="/LearnDataProject/struts/xhtml/validation.js"></script>
> <script type="text/javascript"
> src="/LearnDataProject/struts/utils.js"></script>
>
> but *There isn't the folder 'struts' in my App /LearnDataProject .*
> **
> *Why this happens??? *
Client-side validation requires JavaScript.
Struts 2 serves these JavaScript files from the struts2-core library. If
you look inside the struts2-core library file you will see them.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [Help] I cannot make the Validation in struts 2.0 works.....
Posted by 白鹏 <bi...@gmail.com>.
And this is my *LoginAction-validation.xml: {I check the App folders ,the
xml and LoginAction.class are in the same folder.}*
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator
1.0.2//EN"
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
<validators>
<field name="userName">
<field-validator type="requiredstring">
<message>用户名必填!</message>
</field-validator>
<field-validator type="regex">
<param name="expression"><![CDATA[(\w{4,25}]]></param>
<message>用户名只能是字母和数字,且长度在4到25个字符之间</message>
</field-validator>
</field>
<field name="passwd">
<field-validator type="requiredstring">
<message>密码必填!</message>
</field-validator>
<field-validator type="regex">
<param name="expression"><![CDATA[(\w{4,25})]]></param>
<message>密码只能是字母和数字,且长度在4到25个字符之间</message>
</field-validator>
</field>
<field name="vercode">
<field-validator type="requiredstring">
<message>验证码必填!</message>
</field-validator>
<field-validator type="regex">
<param name="expression"><![CDATA[(\w{6,6})]]></param>
<messag>验证码只能是数字和字母,且长度为6!</message>
</field-validator>
</field>
</validators>
2009/4/13 白鹏 <bi...@gmail.com>
> Hello , the main codes in jsp is:
>
> *log.jsp *
> <s:form method="post" action="/login/login.action" *validation="true"* >
> 用户名:<s:textfield name="userName" /> <br>
> 密码:<s:password name="passwd" /> <br>
> 验证码: <s:textfield name="vercode" /><br>
> 验证码如图:<img src="authImg.do" id="authImg"/> <br>
> 看不清? <a href="log.jsp" onclick="refresh()">单击此处刷新</a>
> <input type="hidden" name="redirectUrl" value="<s:property
> value="redirectUrl"/>"/>
> <input type="submit" value="确定">
> <input type="reset" value="重置">
> </s:form>
>
> *The returned html file contains:*
>
> <script type="text/javascript"
> src="/LearnDataProject/struts/xhtml/validation.js"></script>
> <script type="text/javascript"
> src="/LearnDataProject/struts/utils.js"></script>
>
> but *There isn't the folder 'struts' in my App /LearnDataProject .*
> **
> *Why this happens??? *
> *Thanks for your help! *
>