Skip to content
Snippets Groups Projects
Commit 27c75d02 authored by BEAUVAIS ANTOINE's avatar BEAUVAIS ANTOINE
Browse files

Merge branch 'feature/add_error_page' into 'develop'

:goal: add error controller

See merge request !21
parents d75552a9 f7677b81
Branches
2 merge requests!25Develop,!21:goal_net: add error controller
package fr.unistra.sil.erp.back.controller.web;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
@Controller
public class WebErrorController implements ErrorController {
@RequestMapping("/error")
public String handleError(HttpServletRequest request) {
Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
if (status != null) {
int statusCode = Integer.parseInt(status.toString());
if (statusCode == HttpStatus.NOT_FOUND.value()) {
return "error-404";
} else if (statusCode == HttpStatus.INTERNAL_SERVER_ERROR.value()) {
return "error";
}
}
return "error";
}
}
spring.mvc.static-path-pattern=/static/**
spring.datasource.url=jdbc:sqlite:dev.db
server.error.whitelabel.enabled=false
server.error.path=/error
<!DOCTYPE html>
<html lang="EN">
<body>
<h1>Requested page not found</h1>
<a href="/">Go Home</a>
</body>
</html>
<!DOCTYPE html>
<html lang="EN">
<body>
<h1>Something went wrong! </h1>
<h2>Our Engineers are on it</h2>
<a href="/">Go Home</a>
</body>
</html>
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