首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Struts的validate证验

2012-11-09 
Struts的validate验证1. ActionErrors和ActionError都是ActionMessages的子类,ActionError存放在ActionErr

Struts的validate验证
1. ActionErrors和ActionError都是ActionMessages的子类,ActionError存放在ActionErrors 中,ActionError对象中的参数为配置文件中配置的相应的值,若配置文件中没有配置或配置文件不适合都不能用<htnl:errors        property=""/>输出。
2.错误信息添加用
  ActionErrors errors=new ActionErrors();
  errors.add("error_key",new ActionError("配置文件中的相应的值"))
  注解:void add(java.lang.String property,ActionError error)
在jsp页面中显示错误:<html:errors property="error_key"/>
3.在Action中使用ActionMessages
他有两个add方法:
void add(ActionMessages  message)
             Adds the meesage from the given ActionMessage object  to tjis set of meesage
void add(java.lang.String property,ActionMessage message)
             Add message to the set of message for the specifiled property.

 <p>?</p>
<table cellspacing="0" border="0" style="border-collapse: collapse;" cellpadding="0" width="510">
<tbody>
<tr height="18">
<td align="right" width="25">·</td>
<td width="350">
<a href="http://blog.chinaunix.net/u/1096/showart_476643.html" target="_blank"><span style="font-size: 10pt; color: #02368d;"><strong>Struts入门之四--国际化</strong></span></a>
</td>
<td style="color: #aaaaaa;" width="165">2008-02-06</td>
</tr>
<tr>
<td align="center" colspan="3"><img src="http://blog.chinaunix.net/templates/default/images/right_line.gif" border="0" height="9" alt="Struts的validate证验" width="502" /> </td>
</tr>
<tr height="18">
<td align="right" width="25">·</td>
<td width="350">
<a href="http://blog.chinaunix.net/u/1096/showart_476636.html" target="_blank"><span style="font-size: 10pt; color: #02368d;"><strong>Struts入门之三--页面布局</strong></span></a>
</td>
<td style="color: #aaaaaa;" width="165">2008-02-06</td>
</tr>
<tr>
<td align="center" colspan="3"><img src="http://blog.chinaunix.net/templates/default/images/right_line.gif" border="0" height="9" alt="Struts的validate证验" width="502" /> </td>
</tr>
<tr height="18">
<td align="right" width="25">·</td>
<td width="350">
<a href="http://blog.chinaunix.net/u/1096/showart_476630.html" target="_blank"><span style="font-size: 10pt; color: #02368d;"><strong>Struts入门之二--Struts 验证框架</strong></span></a>
</td>
<td style="color: #aaaaaa;" width="165">2008-02-06</td>
</tr>
<tr>
<td align="center" colspan="3"><img src="http://blog.chinaunix.net/templates/default/images/right_line.gif" border="0" height="9" alt="Struts的validate证验" width="502" /> </td>
</tr>
<tr height="18">
<td align="right" width="25">·</td>
<td width="350">
<a href="http://blog.chinaunix.net/u/1096/showart_336599.html" target="_blank"><span style="font-size: 10pt; color: #02368d;"><strong>Struts入门之一--创建第一个struts程序</strong></span></a>
</td>
<td style="color: #aaaaaa;" width="165">2007-07-09</td>
</tr>
<tr>
<td align="center" colspan="3"><img src="http://blog.chinaunix.net/templates/default/images/right_line.gif" border="0" height="9" alt="Struts的validate证验" width="502" /></td>
</tr>
</tbody>
</table>
<p>?</p>
validate 验证的顺序有点不太赞同了,没按form中的顺序,不知大大家有何见解,讨论下...

18 楼 hpjianhua 2009-07-11   ynabcbit 写道这里可不可以加入动态的提示
我的属性文件的内容是:您的名字的长度为

我想获取输入名字的长度加到提示信息上,如何可以实现

用动态验证框架吧.这样会容易点.至少会自动生成JS代码

热点排行