request.getRequestURI() -> /distributor/checkCaseName/123123
request.getRequestURL() -> http://localhost:8080/distributor/checkCaseName/123123
request.getServletContext().getRealPath("/") ->
/Users/tonnyyi/workspace/CT/simulate-partner/simulate-distributor/target/simulate-distributor-1.0/
request.getServletContext().getRealPath(request.getRequestURI()) ->
/Users/tonnyyi/workspace/CT/simulate-partner/simulate-distributor/target/simulate-distributor-1.0/distributor/checkCaseName/123123
request.getServletPath() -> /checkCaseName/123123
request.getSession().getServletContext().getRealPath("/") ->
/Users/tonnyyi/workspace/CT/simulate-partner/simulate-distributor/target/simulate-distributor-1.0/
Thread.currentThread().getContextClassLoader().getResource("") ->
file:/Users/tonnyyi/workspace/CT/simulate-partner/simulate-distributor/target/simulate-distributor-1.0/WEB-INF/classes/
DispatcherServlet.class.getClassLoader().getResource("") ->
file:/Users/tonnyyi/workspace/CT/simulate-partner/simulate-distributor/target/simulate-distributor-1.0/WEB-INF/classes/
DispatcherServlet.class.getResource("") ->
jar:file:/Users/tonnyyi/workspace/CT/simulate-partner/simulate-distributor/target/simulate-distributor-1.0/WEB-INF/lib/spring-webmvc-4.2.3.RELEASE.jar!/org/springframework/web/servlet/
DispatcherServlet.class.getResource("/") ->
file:/Users/tonnyyi/workspace/CT/simulate-partner/simulate-distributor/target/simulate-distributor-1.0/WEB-INF/classes/
new File("/").getAbsolutePath() -> /
System.getProperty("user.dir") -> /Applications/apache-tomcat-8.0.26/bin
# 摘自spring boot org.springframework.boot.loader.Launcher#createArchive
CodeSource codeSource = getClass().getProtectionDomain().getCodeSource();
URI location = (codeSource != null) ? codeSource.getLocation().toURI() : null;
String path = (location != null) ? location.getSchemeSpecificPart() : null;
System.out.println(path);