作者在 2010-11-02 15:43:41 发布以下内容
Action:
public String execute() throws Exception {
if (this.getUserName().equals("angel") && this.getPassword().equals("123")) {
this.setResult(true);
return SUCCESS;
} else if (this.getUserName().equals("aa")) {
throw new SQLException("the UserException happened");
} else {
throw new Exception();
}
}
struts.xml中的配置:if (this.getUserName().equals("angel") && this.getPassword().equals("123")) {
this.setResult(true);
return SUCCESS;
} else if (this.getUserName().equals("aa")) {
throw new SQLException("the UserException happened");
} else {
throw new Exception();
}
}
<action name="exceptionAction" class="action.ExceptionAction">
<exception-mapping result="exception" exception="SQLException" />
<exception-mapping result="exception" exception="Exception" />
<result name="exception">/exception.jsp</result>
</action>
最后的异常显示:<exception-mapping result="exception" exception="SQLException" />
<exception-mapping result="exception" exception="Exception" />
<result name="exception">/exception.jsp</result>
</action>
<s:property value="exception.message" /><p/>
<s:property value="exceptionStack" />
<s:property value="exceptionStack" />