开发者

SimpleMappingExceptionResolver - Exception not exposed to view

I'm using SimpleMappingExceptionResolver to handling errors, but have a problem to expose exception to the view - it is null. I made an error in some .jsp on purp开发者_如何学Pythonose get error. My configuration below. Throwing the same exception in controller works good. Anybody help with that ?

<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver" p:order="0"/>
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver" p:order="1">
    <property name="defaultErrorView" value="error"/>
</bean> 
<mvc:view-controller path="/error" view-name="error"/>

error.jsp

<h2>Error: ${exception.message}</h2>
<c:if test="${exception == null}">NULL</c:if>

web.xml

<error-page>
  <error-code>500</error-code>
  <location>/error</location>
</error-page>

That works good:

@RequestMapping("/exception")
public void testException() throws Exception {
    throw new org.apache.tiles.definition.NoSuchDefinitionException();
}


I had a similar problem when trying to use SimpleMappingExceptionResolver. The solution I ended up with was not very good so I'm keen to see if someone has a better one. Here is where I got mine from:

http://thinkinginsoftware.blogspot.com/2011/02/handling-errors-in-spring-framework.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜