【发布时间】:2015-11-27 03:16:25
【问题描述】:
我想添加一个相对于 jar 位置的资源文件夹(除了我的 jar 中打包的资源),例如:
/Directory
Application.jar
/resources
test.txt
我尝试了以下方法:
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**")
.addResourceLocations("/resources/", "file:/resources/");
}
我也试过了:
.addResourceLocations("/resources/", "file:resources/");
使用任一设置访问 http://localhost:8080/resources/test.txt 会导致出现白标错误页面。我该如何解决这个问题?
【问题讨论】:
标签: java spring spring-mvc spring-boot