How do I have common error page templates with tiles in a Spring/MVC 3.0 app?

前端 未结 2 1272
心在旅途
心在旅途 2021-01-04 02:59

I have a Spring MVC/3.0 app using tiles as it\'s view, this is working fine however I can\'t figure out how to get the error pages to also use tiles.

I have in my

2条回答
  •  庸人自扰
    2021-01-04 03:41

    It would be just simpler to define error template in tiles:

    
        
    
    

    And handle that with Spring MVC, e.g.:

    @ExceptionHandler({ MissingResourceException.class })
    @ResponseStatus(HttpStatus.NOT_FOUND)
    public String handleMissingResource(Exception e) {
        return "error/404";
    }
    

    In this case, you don't have to add error pages to your web.xml, and one .jsp file per error page will suffice.

提交回复
热议问题