开发者社区 问答 正文

SpringMVC上传文件过大,异常捕获问题。

用 @ExceptionHandler 可以捕获到springMVC抛出的文件过大的异常,但是不会自动跳转到指定的页面。

@ExceptionHandler(Exception.class)
public String handleException(Exception ex) throws Exception {
return "redirect:/fileUpload.jsp";
}

展开
收起
a123456678 2016-03-18 16:04:01 2883 分享 版权
1 条回答
写回答
取消 提交回答
  • ExceptionHandler(MaxUploadSizeExceededException.class)
    public String handleException(MaxUploadSizeExceededException ex) throws Exception {
            return "redirect:/fileUpload.jsp";
            // return "fileUpload";
        }
    2019-07-17 19:06:55
    赞同 展开评论
问答地址: