一、放行静态资源访问的目的:
为了让静态资源不被"springMVC"访问,而被拦截。我们需要让它被"放行"
![](https://img2023.cnblogs.com/blog/2871529/202212/2871529-20221216182235058-1104150185.png)
二、目录结构是什么样?
2.1.1-在main包下
2.1.2-和java包同"级别"
![](https://img2023.cnblogs.com/blog/2871529/202212/2871529-20221216183007300-758075204.png)
2.1.3(我给出的代码,只有在这样的包结构下,在可以使用)
("不然要根据你们自己包位置进行调整")
三、这个"放行静态资源访"要写在"config"包下:
![](https://img2023.cnblogs.com/blog/2871529/202212/2871529-20221216183956807-2080163175.png)
3.1-代码块:
@Configuration
public class SpringMvcSupport extends WebMvcConfigurationSupport {
//当要访问/page/???时候,走走page目录下内容
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/pages/**").addResourceLocations("/pages/");
registry.addResourceHandler("/css/**").addResourceLocations("/css/");
registry.addResourceHandler("/js/**").addResourceLocations("/js/");
registry.addResourceHandler("/plugins/**").addResourceLocations("/plugins/");
}
}