Skip to content
Snippets Groups Projects
Commit 70eb85b9 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

fixed error pages

parent 5ef235ba
No related branches found
No related tags found
No related merge requests found
package de.deadlocker8.budgetmaster.services;
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 ErrorCodeController implements ErrorController
{
@Override
public String getErrorPath()
{
return "/error";
}
@RequestMapping("/error")
public String handleError(HttpServletRequest request)
{
final Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
if(status == null)
{
return "error/500";
}
int statusCode = Integer.parseInt(status.toString());
if(statusCode == HttpStatus.BAD_REQUEST.value())
{
return "error/400";
}
else if(statusCode == HttpStatus.FORBIDDEN.value())
{
return "error/403";
}
else if(statusCode == HttpStatus.NOT_FOUND.value())
{
return "error/404";
}
else if(statusCode == HttpStatus.INTERNAL_SERVER_ERROR.value())
{
return "error/500";
}
return "error/500";
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment