Error page handling

This commit is contained in:
Tim Holloway 2022-01-06 07:48:26 -05:00
parent 8818969564
commit bc368f084c
4 changed files with 21 additions and 3 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
target/
*~

View File

@ -21,6 +21,7 @@ import org.springframework.http.HttpStatus;
public class SpringPrimeFacesApplication {
final String errorPage = "/error/error.html";
final String error404Page = "/error/error404.html";
public static void main(String[] args) {
SpringApplication.run(SpringPrimeFacesApplication.class,
@ -57,7 +58,7 @@ public class SpringPrimeFacesApplication {
public void registerErrorPages(
ErrorPageRegistry registry) {
registry.addErrorPages(new ErrorPage(
HttpStatus.NOT_FOUND, errorPage));
HttpStatus.NOT_FOUND, error404Page));
registry.addErrorPages(new ErrorPage(
HttpStatus.INTERNAL_SERVER_ERROR,
errorPage));

View File

@ -1,9 +1,11 @@
<html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ERROR</title>
</head>
<body>
<h1>Uh-oh!</h1>
An error happened.
<p>An error happened. Check the logs.</p>
<p><a href="/main.jsf">Return to Main Page</a></p>
</body>
</html>

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<title>ERROR - Page Not Found</title>
</head>
<body>
<h1>Page Not Found</h1>
<p>This URL is invalid.</p>
<p><a href="/main.jsf">Return to Main Page</a></p>
</body>
</html>