| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 580 人关注过本帖
标题:struts框架校验,为什么没通过校验直接执行excute方法?
只看楼主 加入收藏
Frain2012
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-10-9
收藏
 问题点数:0 回复次数:2 
struts框架校验,为什么没通过校验直接执行excute方法?
public class Register extends ActionSupport{
    private String username;
    private String password;
    private String password1;
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getPassword1() {
        return password1;
    }
    public void setPassword1(String password1) {
        this.password1 = password1;
    }
    public String execute() throws Exception {
        
        return "su";
    }

}
配置:
<?xml version="1.0" encoding="UTF-8"?>  
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"                           
 "http://www.
<validators>
<field name="username">  
        <field-validator type="requiredstring" short-circuit="true">  
            <param name="trim">true</param>  
            <message>用户名不能为空</message>  
        </field-validator>  
       <field-validator type="stringlength">  
           <param name="minLength">6</param>  
            <param name="maxLength">10</param>  
           <message>用户名必须在${minLength} 和 ${maxLength}之间</message>  
       </field-validator>  
</field>  
<field name="password">
    <field-validator type="stringlength">  
           <param name="minLength">6</param>  
            <param name="maxLength">10</param>  
           <message>用户名必须在${minLength} 和 ${maxLength}之间</message>  
       </field-validator>  
       <field-validator type="requiredstring" short-circuit="true">  
            <param name="trim">true</param>  
            <message>密码不能为空</message>  
        </field-validator>  
</field>
<field name="password1">
    <field-validator type="stringlength">  
           <param name="minLength">6</param>  
            <param name="maxLength">10</param>  
           <message>用户名必须在${minLength} 和 ${maxLength}之间</message>  
       </field-validator>  
       <field-validator type="requiredstring" short-circuit="true">  
            <message>确认密码</message>  
        </field-validator>  
        <field-validator type="fixeldexpressio">
            <param name="expression">password==password1</param>
            <message>确认密码和密码不一致</message>
        </field-validator>
</field>
</validators>
搜索更多相关主题的帖子: password private public return 
2012-10-09 19:04
huxiangwenhu
Rank: 4
等 级:业余侠客
威 望:1
帖 子:191
专家分:262
注 册:2010-6-1
收藏
得分:0 
你需要实现ActionSupport的validate方法才会真正进行校验,校验通过才会进入excute方法
2012-10-12 11:01
leesanchuan
Rank: 2
等 级:论坛游民
威 望:1
帖 子:11
专家分:27
注 册:2012-10-24
收藏
得分:0 
<s:form validate="true">
2012-10-24 09:46
快速回复:struts框架校验,为什么没通过校验直接执行excute方法?
数据加载中...
 
   



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

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