【发布时间】:2011-01-03 11:25:56
【问题描述】:
我有这个控制器:
@RequestMapping(value = "*.xls", method = RequestMethod.GET)
public String excel(Model model) {
return "excel";
excel 视图实际上打开了一个 ExcelViewer,它是内置方法
protected void buildExcelDocument(Map<String, Object> map, WritableWorkbook ww, HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception {
Class.writecontent
Class.writeMoreContent
被调用的方法将内容写入 Excel 工作表,它们可以抛出例如 biffException。发生异常时如何显示某个错误页面?
我试过了
@Controller
public class ExcelController
{
@ExceptionHandler(BiffException.class)
public String handleException(BiffException ex) {
return "fail";
}
@RequestMapping(value = "*.xls", method = RequestMethod.GET)
public String excel(Model model) {
return "excel";
}
}
但是我收到了服务器关于异常的错误消息。也许缺少 bean 定义?
【问题讨论】:
标签: java spring exception-handling spring-mvc