diff --git a/jshERP-boot/src/main/java/com/jsh/erp/filter/LogCostFilter.java b/jshERP-boot/src/main/java/com/jsh/erp/filter/LogCostFilter.java index bd792488..95ac84b5 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/filter/LogCostFilter.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/filter/LogCostFilter.java @@ -10,25 +10,17 @@ import javax.servlet.annotation.WebInitParam; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; @WebFilter(filterName = "LogCostFilter", urlPatterns = {"/*"}, - initParams = {@WebInitParam(name = "ignoredUrl", value = ".ico"), - @WebInitParam(name = "filterPath", - value = "/jshERP-boot/user/login#/jshERP-boot/user/registerUser#/jshERP-boot/user/randomImage#" + - "/jshERP-boot/platformConfig/getPlatform#/jshERP-boot/v2/api-docs#/jshERP-boot/webjars#" + - "/jshERP-boot/systemConfig/static")}) + initParams = {@WebInitParam(name = "filterPath", + value = "/jshERP-boot/user/login#/jshERP-boot/user/registerUser#/jshERP-boot/user/randomImage#" + + "/jshERP-boot/platformConfig/getPlatform#/jshERP-boot/v2/api-docs#/jshERP-boot/webjars#" + + "/jshERP-boot/systemConfig/static")}) public class LogCostFilter implements Filter { private static final String FILTER_PATH = "filterPath"; - private static final String IGNORED_PATH = "ignoredUrl"; - private static final List ignoredList = new ArrayList<>(); private String[] allowUrls; - private String[] ignoredUrls; @Resource private RedisService redisService; @@ -38,15 +30,8 @@ public class LogCostFilter implements Filter { if (!StringUtils.isEmpty(filterPath)) { allowUrls = filterPath.contains("#") ? filterPath.split("#") : new String[]{filterPath}; } - - String ignoredPath = filterConfig.getInitParameter(IGNORED_PATH); - if (!StringUtils.isEmpty(ignoredPath)) { - ignoredUrls = ignoredPath.contains("#") ? ignoredPath.split("#") : new String[]{ignoredPath}; - for (String ignoredUrl : ignoredUrls) { - ignoredList.add(ignoredUrl); - } - } } + @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { @@ -64,10 +49,6 @@ public class LogCostFilter implements Filter { chain.doFilter(request, response); return; } - if (verify(ignoredList, requestUrl)) { - chain.doFilter(servletRequest, response); - return; - } if (null != allowUrls && allowUrls.length > 0) { for (String url : allowUrls) { if (requestUrl.startsWith(url)) { @@ -82,19 +63,6 @@ public class LogCostFilter implements Filter { } } - private static String regexPrefix = "^.*"; - private static String regexSuffix = ".*$"; - - private static boolean verify(List ignoredList, String url) { - for (String regex : ignoredList) { - Pattern pattern = Pattern.compile(regexPrefix + regex + regexSuffix); - Matcher matcher = pattern.matcher(url); - if (matcher.matches()) { - return true; - } - } - return false; - } @Override public void destroy() {