Angular 项目打包之后,部署到springboot项目中,刷新访问404解决方法


解决方法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);
        }


    }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM