JAVA-86: Remove spring-boot-custom-error-page

This commit is contained in:
Krzysiek 2020-03-21 16:19:54 +01:00
parent 3f21f970b8
commit 802d1d3b90
7 changed files with 1 additions and 119 deletions

View File

@ -20,7 +20,6 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
- [Getting Started with GraphQL and Spring Boot](https://www.baeldung.com/spring-graphql)
- [Guide to Spring Type Conversions](https://www.baeldung.com/spring-type-conversions)
- [An Introduction to Kong](https://www.baeldung.com/kong)
- [Spring Boot: Customize Whitelabel Error Page](https://www.baeldung.com/spring-boot-custom-error-page)
- [Spring Boot: Configuring a Main Class](https://www.baeldung.com/spring-boot-main-class)
- [A Quick Intro to the SpringBootServletInitializer](https://www.baeldung.com/spring-boot-servlet-initializer)
- [How to Define a Spring Boot Filter?](https://www.baeldung.com/spring-boot-add-filter)

View File

@ -1,15 +0,0 @@
package com.baeldung.errorhandling;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan(basePackages = "com.baeldung.errorhandling")
public class ErrorHandlingApplication {
public static void main(String [] args) {
System.setProperty("spring.profiles.active", "errorhandling");
SpringApplication.run(ErrorHandlingApplication.class, args);
}
}

View File

@ -1,26 +0,0 @@
package com.baeldung.errorhandling.controllers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
public class IndexController {
@GetMapping(value = {"/", ""})
public String index() {
return "index";
}
@GetMapping(value = {"/server_error"})
public String triggerServerError() {
"ser".charAt(30);
return "index";
}
@PostMapping(value = {"/general_error"})
public String triggerGeneralError() {
return "index";
}
}

View File

@ -1,40 +0,0 @@
package com.baeldung.errorhandling.controllers;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
@Controller
public class MyErrorController implements ErrorController {
public MyErrorController() {}
@GetMapping(value = "/error")
public String handleError(HttpServletRequest request) {
Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
if (status != null) {
Integer statusCode = Integer.valueOf(status.toString());
if(statusCode == HttpStatus.NOT_FOUND.value()) {
return "error-404";
}
else if(statusCode == HttpStatus.INTERNAL_SERVER_ERROR.value()) {
return "error-500";
}
}
return "error";
}
@Override
public String getErrorPath() {
return "/error";
}
}

View File

@ -1,10 +1,4 @@
#server
server.port=9000
server.servlet-path=/
server.context-path=/
#server.error.whitelabel.enabled=false
#spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration
#for Spring Boot 2.0+
#spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration
server.context-path=/

View File

@ -1,14 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
</head>
<body>
<div class="container">
<div class="jumbotron" >
<h1 class="text-center"><i class="fa fa-frown-o"> </i> Sorry, we couldn't find the page you were looking for. </h1>
<p class="text-center"><a class="btn btn-primary" href="/"><i class="fa fa-home"></i>Go Home</a></p>
</div></div>
</body>
</html>

View File

@ -1,16 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
</head>
<body>
<div class="container">
<div class="jumbotron" >
<h1 class="text-center"><i class="fa fa-frown-o"> </i> Sorry, something went wrong! </h1>
<h2 class="text-center">We're fixing it.</h2>
<p class="text-center"><a class="btn btn-primary" href="/"><i class="fa fa-home"></i>Go Home</a></p>
</div></div>
</body>
</html>