首先定義自己的異常類
package com.langhua.oa.manager;
public class systemexception extends runtimeexception
public systemexception(string message, throwable cause)
public systemexception(string message)
public systemexception(throwable cause)
//自己定義的構造方法
public systemexception(string message,string key)
public systemexception(string message,string key,object value);
}public systemexception(string message,string key,object values)
public string getkey()
public object getvalues()
}
再定義systemexceptionhandler extends exceptionhandler
最後在struts的配置檔案上面配置上
在程式中的使用
if(***.getchildren().size()>0)
這個裡面的key就是langhau.error,是指定了的,如果沒有指定的話就會使用配置檔案裡面配置的errors.detail
如果在messageresources.properties配置了langhua.error=error!,錯誤資訊將使用配置檔案裡面的
struts校驗框架的乙個異常
color red cannot load a validator resource from web inf validator rules.xml,web inf validation.xml 異常 color 1.該異常可能是validation.xml裡邊有錯誤,檢查該檔案是否有錯誤 2.確...
乙個簡單的異常處理demo
首先,1.自定義異常類 data public class lyexception extends runtimeexception通過列舉的方式建立異常資訊 getter noargsconstructor allargsconstructor public enum exceptinenums建...
LineDDA的乙個例子
unit unit1 inte ce uses windows,messages,sysutils,variants,classes,graphics,controls,forms,dialogs,extctrls,stdctrls,buttons type tfmmain class tform ...