0
我使用Spring的SimpleMappingExceptionResolver在我的应用如何打印堆栈跟踪Spring MVC中的错误处理程序
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<map>
<entry key="Exception" value="error.htm"/>
</map>
</property>
<property name="defaultErrorView" value="error.htm" />
</bean>
我的错误处理程序也很简单
@Controller
@RequestMapping("error.htm")
public class ErrorController {
@RequestMapping(method = RequestMethod.GET)
public ModelAndView getErrorReport(HttpServletRequest request) {
return new ModelAndView("/WEB-INF/jsp/error.jsp");
}
@RequestMapping(method = RequestMethod.POST)
public ModelAndView getErrorPostReport(HttpServletRequest request,HttpServletResponse response) {
TreeMap<String,Object> map=new TreeMap<String,Object>();
map.put("isDataChange", true);
map.put("isBigError", true);
return new ModelAndView(JSONView.RenderObject(map, response));
}
}
如何打印异常消息和异常堆栈跟踪(或电子邮件)在我的错误控制器?
在此先感谢
UPDATE
感谢您的答复。我想在jsp以及控制台中打印堆栈跟踪。我也想在ErrorController本身中访问对象,这样我就可以使用这些信息发送电子邮件日志(因为一些调用是基于ajax的(他们使用POST),error.jsp在那里不会有用,所以我需要某种方式来访问控制器本身的信息)。
http://stackoverflow.com/questions/4442400/error-page-how-to-print-stack-trace-in-jsp对此有帮助吗? – kommradHomer 2012-04-05 07:31:13
你想在你的jsp或控制台/日志文件上打印堆栈跟踪吗? – powerMicha 2012-04-05 08:55:53