diff --git a/pom.xml b/pom.xml index 724046c..e7fd266 100644 --- a/pom.xml +++ b/pom.xml @@ -1,68 +1,84 @@ - 4.0.0 org.springframework.boot spring-boot-starter-parent 3.3.5 - + com.maradona backend 0.0.1-SNAPSHOT backend Demo project for Spring Boot - + - + - + - - - - + + + + 21 - + + org.springframework.boot spring-boot-starter-web + org.springframework.boot spring-boot-starter-data-jpa + org.springframework.boot spring-boot-starter-thymeleaf + + org.thymeleaf.extras thymeleaf-extras-springsecurity6 + + + - org.projectlombok - lombok - 1.18.30 - provided + org.projectlombok + lombok + 1.18.30 + provided + + + + javax.servlet + javax.servlet-api + 4.0.1 + provided @@ -77,6 +93,7 @@ spring-boot-starter-test test + org.springframework.security spring-security-test @@ -91,18 +108,18 @@ org.springframework.boot spring-boot-maven-plugin - exec - + exec + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.4.1 + + ${project.build.directory}/docs + - - org.apache.maven.plugins - maven-javadoc-plugin - 3.4.1 - - ${project.build.directory}/docs - - - + \ No newline at end of file diff --git a/src/main/java/com/maradona/backend/controllers/page/ErrorPage.java b/src/main/java/com/maradona/backend/controllers/page/ErrorPage.java index b43024d..51a376c 100644 --- a/src/main/java/com/maradona/backend/controllers/page/ErrorPage.java +++ b/src/main/java/com/maradona/backend/controllers/page/ErrorPage.java @@ -1,58 +1,23 @@ package com.maradona.backend.controllers.page; +import org.springframework.boot.web.servlet.error.ErrorController; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; -/** - * Controller for routing to the error pages. - * - * List of endpoints: - * - GET /error/400 - * - GET /error/404 - * - GET /error/500 - */ +import javax.servlet.http.HttpServletRequest; + @Controller -@RequestMapping("/error") -public class ErrorPage { - /** - * Error page for 400 Bad Request. - * - * This page is displayed when the request is malformed and the server cannot - * process it. - * - * @return The 400 error page template. - */ - @GetMapping("/400") - public String error400() { - return "pages/error/400"; - } +public class ErrorPage implements ErrorController { - /** - * Error page for 404 Not Found. - * - * This page is displayed when the requested resource could not be found on the - * server. This can be due to a wrong URL or a deleted resource. The user should - * be informed that the resource is not available. - * - * @return The 404 error page template. - */ - @GetMapping("/404") - public String error404() { - return "pages/error/404"; - } + @RequestMapping("/error") + public String handleError(HttpServletRequest request, Model model) { + Object status = request.getAttribute("javax.servlet.error.status_code"); + Object message = request.getAttribute("javax.servlet.error.message"); - /** - * Error page for 500 Internal Server Error. - * - * This page is displayed when the server encountered an unexpected condition - * that prevented it from fulfilling the request. The user should be informed - * that the server is experiencing problems and the request cannot be processed. - * - * @return The 500 error page template. - */ - @GetMapping("/500") - public String error500() { - return "pages/error/500"; - } -} + model.addAttribute("status", status); + model.addAttribute("message", message); + + return "pages/core/error"; + } +} \ No newline at end of file diff --git a/src/main/java/com/maradona/backend/controllers/page/Page.java b/src/main/java/com/maradona/backend/controllers/page/Page.java index 18a74ac..7ea840a 100644 --- a/src/main/java/com/maradona/backend/controllers/page/Page.java +++ b/src/main/java/com/maradona/backend/controllers/page/Page.java @@ -45,14 +45,4 @@ public class Page { public String datenschutz() { return "pages/core/datenschutz"; } - - /** - * Returns the notes page. - * - * @return The notes page template. - */ - @GetMapping("/notes") - public String notes() { - return "pages/core/notes"; - } } diff --git a/src/main/resources/config/application.yaml b/src/main/resources/config/application.yaml index d04aa3c..2bb8c9b 100644 --- a/src/main/resources/config/application.yaml +++ b/src/main/resources/config/application.yaml @@ -43,3 +43,8 @@ logging: http: converter: json: DEBUG +server: + error: + path: /error + whitelabel: + enabled: false