spring boot访问静态资源报Request method 'GET' not supported

使用springboot+ssm+jsp创建一个项目,并进行访问时,发现页面加载出来了,但是页面引用的样式却报net::ERR_ABORTED 405 (Method Not Allowed)
网上看了很多答案,将post改成get没有效果,求大佬解决!
图片描述

图片描述

图片描述

图片描述

项目目录

配置

阅读 7.6k
4 个回答

springboot 中添加一下static的配置即可。spring.mvc.static-path-pattern: /statics/**

webapp设置了么,还有就是引入位置或者顺序有问题吧

Spring Boot 项目默认资源目录 resources/public
如果想修改的话可以使用如下方式添加

@Configuration
@EnableWebMvc
public class MvcConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry
          .addResourceHandler("/resources/**")
          .addResourceLocations("/resources/"); 
    }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏