如下图: 在浏览器发送请求(http://localhost:8080/backend/index.html)后,报Whitelabel Error Page 404错误。
解决方案:加个配置类,在配置类里设置静态资源映射 (这样,通过浏览器发送的请求(http://localhost:8080/backend/index.html) 就会映射到backend目录下的index.html)
public class WebMvcConfig extends WebMvcConfigurationSupport {
/*
设置静态资源映射
@param registry
*/
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
log.info("开始进行静态资源映射...");
registry.addResourceHandler("/backend/**").addResourceLocations("classpath:/backend/");
registry.addResourceHandler("/front/**").addResourceLocations("classpath:/front/");
}
}