Skip to content

Commit

Permalink
optimize(FrontControllerServlet.java):对启动输出的访问路径自然排序
Browse files Browse the repository at this point in the history
  • Loading branch information
tanpenggood committed Mar 17, 2021
1 parent c4a92de commit 5b1d84e
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
Expand Down Expand Up @@ -71,10 +72,12 @@ public void init(ServletConfig servletConfig) {
String contextPath = servletConfig.getServletContext().getContextPath();
initHandleMethods();
logger.info("all path----------------------------");
List<String> allPaths = handleMethodInfoMapping.keySet().stream()
.sorted(Comparator.naturalOrder()).collect(Collectors.toList());
if (StringUtils.isEmpty(contextPath)) {
handleMethodInfoMapping.keySet().forEach(path -> System.out.println("http://localhost:8080" + path));
allPaths.forEach(path -> System.out.println("http://localhost:8080" + path));
} else {
handleMethodInfoMapping.keySet().forEach(path -> System.out.println(String.format("http://localhost:8080%s%s", contextPath, path)));
allPaths.forEach(path -> System.out.println(String.format("http://localhost:8080%s%s", contextPath, path)));
}
}

Expand Down

0 comments on commit 5b1d84e

Please sign in to comment.