Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsp中的异常处理_Jsp_Exception Handling_Struts - Fatal编程技术网

Jsp中的异常处理

Jsp中的异常处理,jsp,exception-handling,struts,Jsp,Exception Handling,Struts,下午好,在我的时区 我在Web应用程序开发中使用struts框架。 我在struts-config.xml文件中对异常处理进行了参数化: <global-exceptions> <exception key="sap-error" type="com.galpenergia.sgt.util.excepcoes.chained.user.UserException" path="/globalError.jsp"/> <exception key="

下午好,在我的时区

我在Web应用程序开发中使用struts框架。 我在struts-config.xml文件中对异常处理进行了参数化:

<global-exceptions>
    <exception key="sap-error" type="com.galpenergia.sgt.util.excepcoes.chained.user.UserException" path="/globalError.jsp"/>
    <exception key="global-error" type="java.lang.Exception" path="/globalError.jsp"/>
</global-exceptions>

在GlobalErrorJSP中,我有以下页面指令

<%@page isErrorPage="true" %>

当我试图从异常对象获取消息时,它告诉我异常对象为null

<% if(exception != null) {%>
    <%=exception.getMessage() %>
<%}else{ %>
<p>Exception object is null</p>
<% }%>

异常对象为空

为什么会这样

提前谢谢。
我不确定您使用的是哪个Struts版本。我使用的是Struts 1.3.8

如果您使用的是Struts1.X,您可能需要确保您的资源包中有两个异常键。比如:

sap-error = Error in SAP.
global-error = Application crash!
在globalError.jsp中,您必须添加:

<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
...
<html:errors />

...