格式化代码。
parent
c2735937cd
commit
3d2188199c
|
@ -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;
|
||||
|
|
|
@ -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<RequestMappingInfo, HandlerMethod> map = mapping.getHandlerMethods();
|
||||
for (RequestMappingInfo info : map.keySet()) {
|
||||
// 获取url
|
||||
PatternsRequestCondition pathPatternsCondition = info.getPatternsCondition();
|
||||
if (pathPatternsCondition != null) {
|
||||
Set<PathPattern> patterns = pathPatternsCondition.getPatterns()
|
||||
.stream()
|
||||
.map(RequestUtils.defaultPathPatternParserInstance::parse)
|
||||
.collect(Collectors.toSet());
|
||||
for (PathPattern pattern : patterns) {
|
||||
Class<? extends PathPattern> 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<PathPattern> patterns = pathPatternsCondition.getPatterns()
|
||||
.stream()
|
||||
.map(RequestUtils.defaultPathPatternParserInstance::parse)
|
||||
.collect(Collectors.toSet());
|
||||
for (PathPattern pattern : patterns) {
|
||||
Class<? extends PathPattern> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue