解决方法1:
app.module.ts文件添加两行代码:
import { LocationStrategy, HashLocationStrategy } from '@angular/common';
@NgModule({ providers: [ { provide: LocationStrategy, useClass: HashLocationStrategy }, ] })
解决方法2:
在springboot项目application中添加
@Component
public class WebConfig implements ErrorPageRegistrar { @Override
public void registerErrorPages(ErrorPageRegistry registry) {
ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/");
registry.addErrorPages(error404Page);
} }