Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Enhort
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Michael Menzel
Enhort
Commits
8d9a360f
Commit
8d9a360f
authored
Jun 04, 2019
by
Michael Menzel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Setting tomcat max file size and added error redirect on too large file
parent
01044d7c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
frontend/src/main/java/de/thm/spring/controller/ApplicationController.java
.../java/de/thm/spring/controller/ApplicationController.java
+14
-0
frontend/src/main/resources/application.properties
frontend/src/main/resources/application.properties
+1
-0
No files found.
frontend/src/main/java/de/thm/spring/controller/ApplicationController.java
View file @
8d9a360f
...
@@ -26,8 +26,12 @@ import org.springframework.http.HttpStatus;
...
@@ -26,8 +26,12 @@ import org.springframework.http.HttpStatus;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
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.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
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.RequestDispatcher
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -112,6 +116,16 @@ public class ApplicationController implements ErrorController {
...
@@ -112,6 +116,16 @@ public class ApplicationController implements ErrorController {
return
"error"
;
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"
)
@RequestMapping
(
"/faq"
)
public
String
faq
(){
public
String
faq
(){
...
...
frontend/src/main/resources/application.properties
View file @
8d9a360f
...
@@ -5,5 +5,6 @@ logging.level.org.hibernate=INFO
...
@@ -5,5 +5,6 @@ logging.level.org.hibernate=INFO
spring.mvc.favicon.enabled
=
false
spring.mvc.favicon.enabled
=
false
spring.servlet.multipart.max-file-size
=
20MB
spring.servlet.multipart.max-file-size
=
20MB
spring.servlet.multipart.max-request-size
=
20MB
spring.servlet.multipart.max-request-size
=
20MB
server.tomcat.max-swallow-size
=
20971520
#
management.security.enabled
=
false
#
management.security.enabled
=
false
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment