From f028f926ad1c59268c591d1f095f0f77e36a814a Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 31 Jul 2022 07:20:01 -0700 Subject: Better missing file handing --- src/main/java/org/traccar/web/WebServer.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/org/traccar/web/WebServer.java b/src/main/java/org/traccar/web/WebServer.java index 68eee78e7..704a4b3cd 100644 --- a/src/main/java/org/traccar/web/WebServer.java +++ b/src/main/java/org/traccar/web/WebServer.java @@ -64,6 +64,7 @@ import java.io.IOException; import java.io.Writer; import java.net.InetSocketAddress; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.EnumSet; @@ -104,9 +105,9 @@ public class WebServer implements LifecycleObject { @Override protected void handleErrorPage( HttpServletRequest request, Writer writer, int code, String message) throws IOException { - if (code == HttpStatus.NOT_FOUND_404 && request.getPathInfo().startsWith("/modern")) { - writer.write(Files.readString( - Paths.get(config.getString(Keys.WEB_PATH), "modern", "index.html"))); + Path index = Paths.get(config.getString(Keys.WEB_PATH), "index.html"); + if (code == HttpStatus.NOT_FOUND_404 && Files.exists(index)) { + writer.write(Files.readString(index)); } else { writer.write("Error" + code + " - " + HttpStatus.getMessage(code) + ""); -- cgit v1.2.3