From c9cc06dbab54a988bd9bb10494692eebc2c8178a Mon Sep 17 00:00:00 2001 From: wangbing Date: Wed, 11 Mar 2020 10:45:30 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81Properties?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 41ebbf4aff299c696356787e94528c058e02e918 --- .../modules/SpringBoot/java/action/GlobalController.java | 5 ++++- .../modules/SpringBoot/java/frame/utils/UrlUtil.java | 4 ++-- .../resources/templates/control/mint-ui-extend.ftl | 3 +-- .../modules/SpringBoot/resources/templates/control/nav.ftl | 2 -- .../modules/SpringBoot/resources/templates/screen/index.ftl | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/resources/modules/SpringBoot/java/action/GlobalController.java b/src/main/resources/modules/SpringBoot/java/action/GlobalController.java index d6c65eea..d6d04a4d 100644 --- a/src/main/resources/modules/SpringBoot/java/action/GlobalController.java +++ b/src/main/resources/modules/SpringBoot/java/action/GlobalController.java @@ -65,6 +65,8 @@ import java.util.regex.Pattern; @ControllerAdvice public class GlobalController implements ErrorController { + @Value("${r'${server.servlet.context-path}'}") + private String context; @Value("${r'${web.home.page}'}") private String homePage; @Value("${r'${web.login.page}'}") @@ -115,9 +117,10 @@ public class GlobalController implements ErrorController { return "404"; case 403: String errorUrl = RequestUtil.getErrorUrl(request); + errorUrl = errorUrl.replaceFirst(context, ""); if ((errorUrl.equals(homePage) || errorUrl.equals("/")) && LocalData.getToken() == null) { try { - response.sendRedirect("/login.htm"); + response.sendRedirect(context + loginPage); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/resources/modules/SpringBoot/java/frame/utils/UrlUtil.java b/src/main/resources/modules/SpringBoot/java/frame/utils/UrlUtil.java index 6e6c88d4..fd52dc76 100644 --- a/src/main/resources/modules/SpringBoot/java/frame/utils/UrlUtil.java +++ b/src/main/resources/modules/SpringBoot/java/frame/utils/UrlUtil.java @@ -34,8 +34,8 @@ public class UrlUtil { // 端口 int serverPort = request.getServerPort(); // 上下文路径 - String contextPath = request.getContextPath(); + String context = request.getContextPath(); - return String.format(Locale.CHINA, "%s://%s:%d%s%s", scheme, serverName, serverPort, contextPath, url); + return String.format(Locale.CHINA, "%s://%s:%d%s%s", scheme, serverName, serverPort, context, url); } } diff --git a/src/main/resources/modules/SpringBoot/resources/templates/control/mint-ui-extend.ftl b/src/main/resources/modules/SpringBoot/resources/templates/control/mint-ui-extend.ftl index 30b61fa2..80d01fbc 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/control/mint-ui-extend.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/control/mint-ui-extend.ftl @@ -2,8 +2,7 @@ window.nav = new Vue({ data: { activeIndex: 'home', - contextPath: '${contextPath?default("")}', - homePath: '${homePath?default("")}', + context: '${context?default("")}', tip: { show: function (msg) { if(msg) { diff --git a/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl b/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl index 75340564..c87789a7 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl @@ -238,7 +238,6 @@ data: { activeIndex: 'home', context: '${context?default("")}', - homePath: '${home?default("")}', isSubmit: false, result: [], select: [] @@ -422,7 +421,6 @@ loadingTip: '', loadingBar: '', context: '${context?default("")}', - homePath: '${home?default("")}' }, methods: { tipShow: function (msg) { diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl index 92e93477..45153775 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl @@ -312,7 +312,7 @@ this.addTab({ title: '首页', name: 'home', - url: '${r"${contextPath}"}/home.htm' + url: '${r"${context}"}/home.htm' }) }, barStart: function () {