ExceptionHandling with Spring 3

Posted by mjf on Stack Overflow See other posts from Stack Overflow or by mjf
Published on 2011-01-03T11:25:56Z Indexed on 2011/01/03 12:54 UTC
Read the original article Hit count: 231

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?

© Stack Overflow or respective owner

Related posts about java

Related posts about spring