【发布时间】:2014-01-15 11:12:21
【问题描述】:
我在下面有我的Action 类,其中getTspNameIdMap 抛出ReqMgmtException 异常(自定义异常)。
public String findTspNameIdMap(){
SlsReqMgmtCommonRemote slsReqMgmtCommonRemote = null;
tspNameIdMap = new HashMap<String, String>();
try{
slsReqMgmtCommonRemote = getSlsReqMgmtCommonRemote();
tspNameIdMap = slsReqMgmtCommonRemote.getTspNameIdMap(gmaThresholdParameters.getId().getCircleId());
}
catch(ReqMgmtException rEx){
addActionError(rEx.getError());
result = "error";
return ERROR;
}
catch (Exception e){
addActionError("Error in processing your request. Contact Administrator");
e.printStackTrace();
System.out.println("[ConfigureTspThresholdAction: findTspNameIdMap Function]:In catch Inside Constructor!!");
result = "error";
return ERROR;
}
return SUCCESS;
}
我知道 Struts2 中也有异常处理,但是目前我没有使用它。 我应该使用 Struts2 异常处理吗?它的用途是什么?
【问题讨论】:
-
您是否“应该”使用 S2 的声明式异常处理完全取决于您的需要。它用于处理您不想直接在应用程序代码中处理的异常。
标签: java jsp exception-handling struts2