From 1da3e4ddb5a87d4211ebc60b5398174781207c44 Mon Sep 17 00:00:00 2001 From: zhengjw22 Date: Thu, 14 Nov 2024 20:05:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/tech/smartboot/servlet/DefaultServlet.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/servlet-core/src/main/java/tech/smartboot/servlet/DefaultServlet.java b/servlet-core/src/main/java/tech/smartboot/servlet/DefaultServlet.java index a3c4d8b..9dd863c 100644 --- a/servlet-core/src/main/java/tech/smartboot/servlet/DefaultServlet.java +++ b/servlet-core/src/main/java/tech/smartboot/servlet/DefaultServlet.java @@ -238,10 +238,14 @@ private boolean matchForwardWelcome(HttpServletRequest request, HttpServletRespo if (deploymentInfo.getWelcomeFiles().stream().anyMatch(requestUri::endsWith) || requestUri.indexOf(".") > 0) { return false; } - if (requestUri.equals(request.getContextPath())) { + URL url = servletContext.getResource(requestUri.substring(request.getContextPath().length()) + "/"); + if (url != null) { response.sendRedirect(requestUri + "/"); +// request.getRequestDispatcher(requestUri.substring(request.getContextPath().length()) + "/").forward(request, response); return true; } +// URL url = servletContext.getResource(requestUri.substring(request.getContextPath().length()) + "/"); + return false; }