From 54a0a8ac4a62d65cc340e670b82ffdce04688e47 Mon Sep 17 00:00:00 2001 From: Michael Menzel Date: Tue, 4 Jun 2019 15:43:20 +0200 Subject: [PATCH] fixed error redirect on file size too large --- .../controller/ApplicationController.java | 18 ++++++++++++++++-- .../src/main/resources/templates/error.html | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/frontend/src/main/java/de/thm/spring/controller/ApplicationController.java b/frontend/src/main/java/de/thm/spring/controller/ApplicationController.java index 15e7b711..f400a46c 100644 --- a/frontend/src/main/java/de/thm/spring/controller/ApplicationController.java +++ b/frontend/src/main/java/de/thm/spring/controller/ApplicationController.java @@ -121,11 +121,25 @@ public class ApplicationController implements ErrorController { @ExceptionHandler(MultipartException.class) String handleFileException(HttpServletRequest request, Throwable ex, Model model) { - model.addAttribute("errorMessage", "The file you tried to upload is too large. Please upload only files with a max. file size of 20 MB."); - return "error"; + + return "redirect:/filesizetoolarge"; } } + /** + * File exceptions are redirected to this method to call 'error' with in a post request with the message + * + * @param model - same as always + * @return the error page + */ + @RequestMapping("/filesizetoolarge") + public String filesizetoolarge(Model model){ + + model.addAttribute("errorMessage", "The file you tried to upload is too large. Please upload only files with a max. file size of 20 MB."); + + return "error"; + } + @RequestMapping("/faq") public String faq(){ diff --git a/frontend/src/main/resources/templates/error.html b/frontend/src/main/resources/templates/error.html index c2c84b4a..07bd2f50 100644 --- a/frontend/src/main/resources/templates/error.html +++ b/frontend/src/main/resources/templates/error.html @@ -23,7 +23,7 @@ back
-

Something went wrong

+
Something went wrong:

-- GitLab