对action所有方法进行输入校验validate()方法

1.需要使用validate方法
validate 方法继承 actionsupport类

2 验证错误结果需要在本类的this.addFieldError(验证参数,传递数据);
this.addFieldError("username""user can not be null");

3.struts.xml中 需要由input是struts2专门验证的参数必须这么写,是内部继承的与
this.addFieldError关联<result name="input">/index.jsp</result>跳转到结果错误提示视图
<action name="manage_*" class="cn.itcast.action.PersonAction" method="{1}">
            
<!-- 错误输出时候会调用系统自带的input视图 -->
            
<result name="input">/index.jsp</result>
            
<result name="message">/WEB-INF/page/message.jsp</result>
            
        
</action>
4验证结果输出jsp页面需要导入
<%@taglib uri="/struts-tags" prefix="s"%>
sturts2标签,
<s:fielderror/>
为输出结果
“user can not be 
null

posted on 2012-06-07 15:19 youngturk 阅读(276) 评论(0)  编辑  收藏 所属分类: struts2


只有注册用户登录后才能发表评论。


网站导航:
 
<2012年6月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

导航

统计

公告

this year :
1 jQuery
2 freemarker
3 框架结构
4 口语英语

常用链接

留言簿(6)

随笔分类

随笔档案

文章分类

文章档案

相册

EJB学习

Flex学习

learn English

oracle

spring MVC web service

SQL

Struts

生活保健

解析文件

搜索

最新评论

阅读排行榜

评论排行榜