新聞中心
Struts validate驗證

成都創(chuàng)新互聯(lián)公司成都網(wǎng)站建設(shè)按需網(wǎng)站建設(shè),是成都網(wǎng)站建設(shè)公司,為地磅秤提供網(wǎng)站建設(shè)服務(wù),有成熟的網(wǎng)站定制合作流程,提供網(wǎng)站定制設(shè)計服務(wù):原型圖制作、網(wǎng)站創(chuàng)意設(shè)計、前端HTML5制作、后臺程序開發(fā)等。成都網(wǎng)站改版熱線:18982081108
1. ActionErrors和ActionError都是ActionMessages的子類,ActionError存放在ActionErrors 中,ActionError對象中的參數(shù)為配置文件中配置的相應的值,若配置文件中沒有配置或配置文件不適合都不能用 < htnl:errors property=""/>輸出。
2.錯誤信息添加用
ActionErrors errors=new ActionErrors();
errors.add("error_key",new ActionError("配置文件中的相應的值"))
注解:void add(java.lang.String property,ActionError error)
在jsp頁面中顯示錯誤:
3.在Action中使用ActionMessages 他有兩個add方法:
他有兩個add方法:
void add(ActionMessages message) |
錯誤信息添加使用errors.add("error_key",new ActionMessage("errors.loginerror"))
另外要調(diào)用this.saveMessages(request,errors)方法;
這是org.apache.structs.action.Action中 的方法,要用到的大概有兩個:
1.saveErrors(少用)
protected void saveErrors(java.servlet,http.HttoServletRequest request,ActionErrors errors)
Save the specifiled error message keys into the appropriate request attribute for use by the
tag,if any message are required.Otherwise,ensure that the request attribute is not created.
2.saveMessage(常用)
protect void saveMessage(javax.Servlet.http.HttpServletRequest request,ActionMessages messages)
Save the specified message keys into the appropriate request attribute for use by the
if messages="true" is set},if any message are required,Otherwise,ensure that the request attribute is not
created.
ActionErrors actionMessages ,ActionMessage ActionMessage是繼承關(guān)系,父類在前,子類在后
if (!loadForm.getUsername().equals("123")) {
|
FORM里面
public ActionErrors validate(ActionMapping mapping, |
【編輯推薦】
- 在Eclipse中開發(fā)struts應用程序
- 手把手教你在Eclipse中配置開發(fā)Struts
- Eclipse下開發(fā)struts完整解決亂碼問題
- Struts相關(guān)背景介紹
- 使用Easy Struts for Eclipse開發(fā)Struts
文章題目:Strutsvalidate驗證的具體實現(xiàn)
網(wǎng)頁網(wǎng)址:http://fisionsoft.com.cn/article/dpjoghh.html


咨詢
建站咨詢
