classpath
引用自
https://www.cnblogs.com/daihu/p/13851519.html
一、classpath指向了哪里
1、用maven构建(build)项目时,默认的classpath指向target/classes/
2、用maven打包(package)项目时,默认的classpath指向war内部的WEB-INF/classes/
二、如果获取springboot项目默认的classpath
// 获取classpath
String classpath = ResourceUtils.getURL("classpath:").getPath();
路径写法
指需要定位到绝对路径时,必须加file
静态资源映射路径配置
引用自
https://www.cnblogs.com/pomer-huang/archive/2018/09/12/pomer.html
- 无任何前缀 -> “文档根目录”(一般指代 src/main/webapp 目录), 例如 localhost:8080/index.html 定位至 src/main/webapp/static/index.html
- 存在前缀 classpath -> 类路径(一般指代 src/main/resources 目录)
- 存在前缀 file:// -> 文件系统路径(“绝对路径”)
案例
无前缀,访问src目录下的webapp