diff --git a/src/main/java/com/nantian/mfp/framework/config/SecurityConfig.java b/src/main/java/com/nantian/mfp/framework/config/SecurityConfig.java index 5d12553..8d1e1ce 100644 --- a/src/main/java/com/nantian/mfp/framework/config/SecurityConfig.java +++ b/src/main/java/com/nantian/mfp/framework/config/SecurityConfig.java @@ -6,7 +6,6 @@ import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.authentication.AuthenticationManager; diff --git a/src/main/java/com/nantian/mfp/framework/config/WebMvcConfig.java b/src/main/java/com/nantian/mfp/framework/config/WebMvcConfig.java index 810ac2d..d2eba52 100644 --- a/src/main/java/com/nantian/mfp/framework/config/WebMvcConfig.java +++ b/src/main/java/com/nantian/mfp/framework/config/WebMvcConfig.java @@ -52,25 +52,23 @@ public class WebMvcConfig implements WebMvcConfigurer, CommandLineRunner { public void run(String... args) throws Exception { try { RequestMappingHandlerMapping mapping = MfpContextHolder.getBean(RequestMappingHandlerMapping.class); - //获取url与类和方法的对应信息 + // 获取url与类和方法的对应信息 Map map = mapping.getHandlerMethods(); for (RequestMappingInfo info : map.keySet()) { // 获取url PatternsRequestCondition pathPatternsCondition = info.getPatternsCondition(); - if (pathPatternsCondition != null) { - Set patterns = pathPatternsCondition.getPatterns() - .stream() - .map(RequestUtils.defaultPathPatternParserInstance::parse) - .collect(Collectors.toSet()); - for (PathPattern pattern : patterns) { - Class aClass = pattern.getClass(); - Field field = aClass.getDeclaredField("capturedVariableCount"); - field.setAccessible(true); - int num = (int) field.get(pattern); - //不为0说明路径包含@PathVariable变量 - if (num != 0) { - patternList.add(pattern); - } + Set patterns = pathPatternsCondition.getPatterns() + .stream() + .map(RequestUtils.defaultPathPatternParserInstance::parse) + .collect(Collectors.toSet()); + for (PathPattern pattern : patterns) { + Class aClass = pattern.getClass(); + Field field = aClass.getDeclaredField("capturedVariableCount"); + field.setAccessible(true); + int num = (int) field.get(pattern); + // 不为0说明路径包含@PathVariable变量 + if (num != 0) { + patternList.add(pattern); } } }