
原因是因为没有定义404的页面,只需要在Springboot中加入如下代码即可
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
@Configuration
public class ServletConfig {
@Bean
public WebServerFactoryCustomizer webServerFactoryCustomizer() {
return factory -> {
ErrorPage errorPage = new ErrorPage(HttpStatus.NOT_FOUND,"/index.html");
factory.addErrorPages(errorPage);
};
}
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)