From 42abb033aba159f2541631627fc62f309ce15330 Mon Sep 17 00:00:00 2001 From: tanghc Date: Thu, 14 Nov 2019 19:25:24 +0800 Subject: [PATCH] 2.5.3 --- .../manager/ServiceRouteInfoBuilder.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/ServiceRouteInfoBuilder.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/ServiceRouteInfoBuilder.java index 59871a53..2c2d7a68 100644 --- a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/ServiceRouteInfoBuilder.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/ServiceRouteInfoBuilder.java @@ -79,7 +79,7 @@ public class ServiceRouteInfoBuilder { } protected String buildServletPath(ServiceApiInfo serviceApiInfo, ServiceApiInfo.ApiMeta apiMeta) { - String contextPath = environment.getProperty("server.servlet.context-path", getContextPathForOld()); + String contextPath = getContextPathCompatibility(); String servletPath = apiMeta.getPath(); if (servletPath == null) { servletPath = ""; @@ -95,11 +95,13 @@ public class ServiceRouteInfoBuilder { } /** - * 兼容老版本获取context-path - * @return 返回context-path,没有返回/ + * 获取context-path,兼容老版本 + * @return 返回context-path,没有返回"/" */ - private String getContextPathForOld() { - return environment.getProperty("server.context-path", DEFAULT_CONTEXT_PATH); + private String getContextPathCompatibility() { + return environment.getProperty("server.servlet.context-path", + environment.getProperty("server.context-path", DEFAULT_CONTEXT_PATH) + ); } private void checkPath(String path, String errorMsg) {