报错信息:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sat Mar 18 16:30:52 CST 2023
There was an unexpected error (type=Not Found, status=404).
错误分析:
静态资源未放置在Static目录下,访问不到静态页面
解决方法:
1.在文件系统下新建static文件夹,将资源移入
2.新建一个配置类,对资源进行映射,代码如下
package com.raggie.config; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; @Configuration public class WebMvcConfig extends WebMvcConfigurationSupport { @Override protected void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/backend/**").addResourceLocations("classpath:/backend/"); registry.addResourceHandler("/front/**").addResourceLocations("classpath:/front/"); } }