//测试路径
//获取项目编译路径
String path1 = this.getClass().getResource("/").getPath();
System.out.println("path1路径为:" + path1);
//获取当前类的加载目录
String path2 = this.getClass().getResource("").getPath();
System.out.println("path2路径为:" + path2);
//获取项目根路径
String path3 = System.getProperty("user.dir");
System.out.println("path3路径为:" + path3);
//获取所有的类路径,包括jar的路径
String path4 = System.getProperty("java.class.path");
System.out.println("path4路径为:" + path4);
URL path5 = this.getClass().getClassLoader().getResource("");
System.out.println("URL路径为:" + path5);
String path6 = Thread.currentThread().getContextClassLoader().getResource("").getPath();
System.out.println("path6路径为:" + path6);
String path7 = request.getSession().getServletContext().getRealPath("/");
System.out.println("path7路径为:" + path7);
String path8 = request.getSession().getServletContext().getRealPath("");
System.out.println("path8路径为:" + path8);
String scheme = request.getScheme();//http
String serverName = request.getServerName();//localhost
int serverPort = request.getServerPort();//8080
String contextPath = request.getContextPath();//项目名
String url = scheme+"://"+serverName+":"+serverPort+contextPath;//http://127.0.0.1:8080/test
path1路径为:/D:/ueditor/ueditor/target/classes/
path2路径为:/D:/ueditor/ueditor/target/classes/com/example/ueditor/
path3路径为:D:\ueditor\ueditor
path4路径为:E:\jdkjar\jre\lib\charsets.jar;E:\jdkjar\jre\lib\deploy.jar;E:\jdkjar\jre\lib\ext\access-bridge-64.jar;E:\jdkjar\jre\lib\ext\cldrdata.jar;E:\jdkjar\jre\lib\ext\dnsns.jar;E:\jdkjar\jre\lib\ext\jaccess.jar;E:\jdkjar\jre\lib\ext\jfxrt.jar;E:\jdkjar\jre\lib\ext\localedata.jar;E:\jdkjar\jre\lib\ext\nashorn.jar;E:\jdkjar\jre\lib\ext\sunec.jar;E:\jdkjar\jre\lib\ext\sunjce_provider.jar;E:\jdkjar\jre\lib\ext\sunmscapi.jar;E:\jdkjar\jre\lib\ext\sunpkcs11.jar;E:\jdkjar\jre\lib\ext\zipfs.jar;E:\jdkjar\jre\lib\javaws.jar;E:\jdkjar\jre\lib\jce.jar;E:\jdkjar\jre\lib\jfr.jar;E:\jdkjar\jre\lib\jfxswt.jar;E:\jdkjar\jre\lib\jsse.jar;E:\jdkjar\jre\lib\management-agent.jar;E:\jdkjar\jre\lib\plugin.jar;E:\jdkjar\jre\lib\resources.jar;E:\jdkjar\jre\lib\rt.jar;D:\ueditor\ueditor\target\classes;E:\maven\mavenspace\org\springframework\boot\spring-boot-starter-web\2.3.1.RELEASE\spring-boot-starter-web-2.3.1.RELEASE.jar;E:\maven\mavenspace\org\springframework\boot\spring-boot-starter\2.3.1.RELEASE\spring-boot-starter-2.3.1.RELEASE.jar;E:\maven\mavenspace\org\springframework\boot\spring-boot-starter-logging\2.3.1.RELEASE\spring-boot-starter-logging-2.3.1.RELEASE.jar;E:\maven\mavenspace\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;E:\maven\mavenspace\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;E:\maven\mavenspace\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;E:\maven\mavenspace\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;E:\maven\mavenspace\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;E:\maven\mavenspace\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;E:\maven\mavenspace\org\yaml\snakeyaml\1.26\snakeyaml-1.26.jar;E:\maven\mavenspace\org\springframework\boot\spring-boot-starter-json\2.3.1.RELEASE\spring-boot-starter-json-2.3.1.RELEASE.jar;E:\maven\mavenspace\com\fasterxml\jackson\core\jackson-databind\2.11.0\jackson-databind-2.11.0.jar;E:\maven\mavenspace\com\fasterxml\jackson\core\jackson-annotations\2.11.0\jackson-annotations-2.11.0.jar;E:\maven\mavenspace\com\fasterxml\jackson\core\jackson-core\2.11.0\jackson-core-2.11.0.jar;E:\maven\mavenspace\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.11.0\jackson-datatype-jdk8-2.11.0.jar;E:\maven\mavenspace\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.11.0\jackson-datatype-jsr310-2.11.0.jar;E:\maven\mavenspace\com\fasterxml\jackson\module\jackson-module-parameter-names\2.11.0\jackson-module-parameter-names-2.11.0.jar;E:\maven\mavenspace\org\springframework\boot\spring-boot-starter-tomcat\2.3.1.RELEASE\spring-boot-starter-tomcat-2.3.1.RELEASE.jar;E:\maven\mavenspace\org\apache\tomcat\embed\tomcat-embed-core\9.0.36\tomcat-embed-core-9.0.36.jar;E:\maven\mavenspace\org\glassfish\jakarta.el\3.0.3\jakarta.el-3.0.3.jar;E:\maven\mavenspace\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.36\tomcat-embed-websocket-9.0.36.jar;E:\maven\mavenspace\org\springframework\spring-web\5.2.7.RELEASE\spring-web-5.2.7.RELEASE.jar;E:\maven\mavenspace\org\springframework\spring-beans\5.2.7.RELEASE\spring-beans-5.2.7.RELEASE.jar;E:\maven\mavenspace\org\springframework\spring-webmvc\5.2.7.RELEASE\spring-webmvc-5.2.7.RELEASE.jar;E:\maven\mavenspace\org\springframework\spring-aop\5.2.7.RELEASE\spring-aop-5.2.7.RELEASE.jar;E:\maven\mavenspace\org\springframework\spring-context\5.2.7.RELEASE\spring-context-5.2.7.RELEASE.jar;E:\maven\mavenspace\org\springframework\spring-expression\5.2.7.RELEASE\spring-expression-5.2.7.RELEASE.jar;E:\maven\mavenspace\org\springframework\boot\spring-boot-starter-thymeleaf\2.3.1.RELEASE\spring-boot-starter-thymeleaf-2.3.1.RELEASE.jar;E:\maven\mavenspace\org\thymeleaf\thymeleaf-spring5\3.0.11.RELEASE\thymeleaf-spring5-3.0.11.RELEASE.jar;E:\maven\mavenspace\org\thymeleaf\thymeleaf\3.0.11.RELEASE\thymeleaf-3.0.11.RELEASE.jar;E:\maven\mavenspace\org\attoparser\attoparser\2.0.5.RELEASE\attoparser-2.0.5.RELEASE.jar;E:\maven\mavenspace\org\unbescape\unbescape\1.1.6.RELEASE\unbescape-1.1.6.RELEASE.jar;E:\maven\mavenspace\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;E:\maven\mavenspace\org\thymeleaf\extras\thymeleaf-extras-java8time\3.0.4.RELEASE\thymeleaf-extras-java8time-3.0.4.RELEASE.jar;E:\maven\mavenspace\org\mybatis\spring\boot\mybatis-spring-boot-starter\2.1.3\mybatis-spring-boot-starter-2.1.3.jar;E:\maven\mavenspace\org\springframework\boot\spring-boot-starter-jdbc\2.3.1.RELEASE\spring-boot-starter-jdbc-2.3.1.RELEASE.jar;E:\maven\mavenspace\com\zaxxer\HikariCP\3.4.5\HikariCP-3.4.5.jar;E:\maven\mavenspace\org\springframework\spring-jdbc\5.2.7.RELEASE\spring-jdbc-5.2.7.RELEASE.jar;E:\maven\mavenspace\org\springframework\spring-tx\5.2.7.RELEASE\spring-tx-5.2.7.RELEASE.jar;E:\maven\mavenspace\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\2.1.3\mybatis-spring-boot-autoconfigure-2.1.3.jar;E:\maven\mavenspace\org\mybatis\mybatis\3.5.5\mybatis-3.5.5.jar;E:\maven\mavenspace\org\mybatis\mybatis-spring\2.0.5\mybatis-spring-2.0.5.jar;E:\maven\mavenspace\org\springframework\boot\spring-boot-devtools\2.3.1.RELEASE\spring-boot-devtools-2.3.1.RELEASE.jar;E:\maven\mavenspace\org\springframework\boot\spring-boot\2.3.1.RELEASE\spring-boot-2.3.1.RELEASE.jar;E:\maven\mavenspace\org\springframework\boot\spring-boot-autoconfigure\2.3.1.RELEASE\spring-boot-autoconfigure-2.3.1.RELEASE.jar;E:\maven\mavenspace\org\projectlombok\lombok\1.18.12\lombok-1.18.12.jar;E:\maven\mavenspace\commons-codec\commons-codec\1.9\commons-codec-1.9.jar;E:\maven\mavenspace\commons-fileupload\commons-fileupload\1.3.2\commons-fileupload-1.3.2.jar;E:\maven\mavenspace\commons-io\commons-io\2.4\commons-io-2.4.jar;E:\maven\mavenspace\com\gitee\qdbp\thirdparty\ueditor\1.4.3.3\ueditor-1.4.3.3.jar;E:\maven\mavenspace\com\alibaba\fastjson\1.2.47\fastjson-1.2.47.jar;E:\maven\mavenspace\org\springframework\spring-core\5.2.7.RELEASE\spring-core-5.2.7.RELEASE.jar;E:\maven\mavenspace\org\springframework\spring-jcl\5.2.7.RELEASE\spring-jcl-5.2.7.RELEASE.jar;E:\idea\IntelliJ IDEA 2019.3.3\lib\idea_rt.jar;C:\Users\admin\.IntelliJIdea2019.3\system\captureAgent\debugger-agent.jar
URL路径为:file:/D:/ueditor/ueditor/target/classes/
path6路径为:/D:/ueditor/ueditor/target/classes/
path7路径为:C:\Users\admin\AppData\Local\Temp\tomcat-docbase.6667479160196890445.8888\
path8路径为:C:\Users\admin\AppData\Local\Temp\tomcat-docbase.6667479160196890445.8888\
scheme路径为:http
serverName路径为:localhost
serverPort路径为:8888
contextPath路径为:
url路径为:http://localhost:8888
(项目路径设为“/”,所以不显示)
网友评论