ExceptionHandling with Spring 3
- by mjf
I have this controller:
@RequestMapping(value = "*.xls", method = RequestMethod.GET)
public String excel(Model model) {
return "excel";
The excel wiew opens actually a ExcelViewer, which is build in method
protected void buildExcelDocument(Map<String, Object> map, WritableWorkbook ww, HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception {
Class.writecontent
Class.writeMoreContent
Called methods write content to the Excel sheet and they can throw e.g biffException. How can I show a certain error page when Exception is occured?
I tried this
@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";
}
}
But I'm getting the server's error message about Exceptions. Maybe a bean definition missing?