Spring Boot无法找到图标 No mapping for
作者:
忘记_3a6a | 来源:发表于
2020-03-09 09:51 被阅读0次报错
.s.web.servlet.PageNotFound : No mapping for GET /favicon.ico
原因
解决方法
import com.qing.music.result.ResponseResultInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Autowired
private ResponseResultInterceptor responseResultInterceptor;
//统一返回值拦截
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(responseResultInterceptor).addPathPatterns("/**");
}
//解决 No mapping for GET /favicon.ico 访问静态资源图标
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**")
.addResourceLocations("classpath:/static/")
.addResourceLocations("classpath:/META-INF/resources/");
}
}
本文标题:Spring Boot无法找到图标 No mapping for
本文链接:https://www.haomeiwen.com/subject/zuqudhtx.html
网友评论