在Spring中,资源处理程序正常运行
<mvc:resources mapping="/Lab/**" location="/WEB-INF/Assets/Lab/"/>
<mvc:resources mapping="/Tools/**" location="/WEB-INF/Assets/Tools/"/>
<mvc:resources mapping="/Images/**" location="/WEB-INF/Assets/Images/"/>
如何在spring boot中添加多个资源?
以下代码无效
@Configuration
@EnableWebMvc
public class ResourceHandlers extends WebMvcConfigurerAdapter
{
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry)
{
registry
.addResourceHandler("/Lab/**")
.addResourceLocations("/WEB-INF/Assets/Lab/");
registry
.addResourceHandler("/Tools/**")
.addResourceLocations("/WEB-INF/Assets/Tools/");
registry
.addResourceHandler("/Images/**")
.addResourceLocations("/WEB-INF/Assets/Images/");
}
}
答案 0 :(得分:4)
registry
.addResourceHandler("/Lab/**", "/Tools/**", "/Images/**")
.addResourceLocations("/WEB-INF/Assets/Lab/",
"/WEB-INF/Assets/Tools/",
"/WEB-INF/Assets/Images/");
它允许多个参数