我有以下
web.xml
<error-page>
<error-code>500</error-code>
<location>/WEB-INF/views/errorPages/500.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/WEB-INF/views/errorPages/error.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/WEB-INF/views/errorPages/500.jsp</location>
</error-page>
弹簧上下文.xml
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="java.lang.Exception">error</prop>
</props>
</property>
</bean>
<bean id="exceptionResolver"
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="com.company.server.exception.GenericException">GenericExceptionPage</prop>
<prop key="java.lang.Exception">error</prop>
</props>
</property>
<property name="defaultErrorView" value="defaulterror"></property>
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
通用异常.java
public class GenericException extends RuntimeException
{
private static final long serialVersionUID = 1L;
private String customMsg;
public String message;
public String getCustomMsg()
{
return customMsg;
}
public void setCustomMsg(String customMsg)
{
this.customMsg = customMsg;
}
public GenericException(String customMsg)
{
this.customMsg = customMsg;
}
@Override
public String getMessage()
{
return message;
}
}
myController.java
@Controller
@RequestMapping(value = "/admin/store")
public class AdminController
{
//bunch of restful drivin requestMappings
}
问题:如何获取所有内部服务器错误和异常以将异常/错误消息显示到单个页面?