GitLab ist jetzt auf dem neuesten Stand! Die jüngsten Probleme wurden behoben. Wir entschuldigen uns für die dadurch verursachten Unannehmlichkeiten.

Commit 8d9a360f authored by Michael Menzel's avatar Michael Menzel

Setting tomcat max file size and added error redirect on too large file

parent 01044d7c
......@@ -26,8 +26,12 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartException;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
......@@ -112,6 +116,16 @@ public class ApplicationController implements ErrorController {
return "error";
}
@ControllerAdvice
public class FileErrorController extends ResponseEntityExceptionHandler {
@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";
}
}
@RequestMapping("/faq")
public String faq(){
......
......@@ -5,5 +5,6 @@ logging.level.org.hibernate=INFO
spring.mvc.favicon.enabled = false
spring.servlet.multipart.max-file-size=20MB
spring.servlet.multipart.max-request-size=20MB
server.tomcat.max-swallow-size=20971520
#management.security.enabled=false
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment