67,512
社区成员
发帖
与我相关
我的任务
分享
<bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="defaultErrorView" value="failure" />
<property name="exceptionMappings">
<props>
<prop key="java.lang.RuntimeException">exception</prop>
</props>
</property>
</bean>
@Controller
public class ExceptionResolver extends AbstractHandlerExceptionResolver{
private Log log = LogFactory.getLog(ExceptionResolver.class);
@Override
protected ModelAndView doResolveException(
HttpServletRequest httpservletrequest,
HttpServletResponse httpservletresponse, Object obj,
Exception exception) {
ModelAndView mv = new ModelAndView("exception");
log.debug(exception.getMessage(),exception);
mv.addObject("exception", exception);
return mv;
}
}