为addResourceHandler("/*.text")
工作正常时,为什么addResourceHandler("/*.js")
无效?
如果spring不支持文本文件资源处理程序,我们如何以其他方式实现呢?
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
//not work,localhost:8181/test.text get "HTTP Status 404 The requested resource is not available."
if (!registry.hasMappingForPattern("/*.text")) {
registry.addResourceHandler("/*.text").addResourceLocations("/static/text/");
}
//works fine,localhost:8181/test.js get the right file
if (!registry.hasMappingForPattern("/*.js")) {
registry.addResourceHandler("/*.js").addResourceLocations("/static/js/");
}
}