栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在Apache Tomcat 404深度链接上部署角度应用程序

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在Apache Tomcat 404深度链接上部署角度应用程序

我设法通过以下步骤解决了此问题,例如http:// localhost:8080 / angular / player / detail /
4

1)使用以下命令构建角度应用程序:ng build –prod -bh ./ -d / angular

2)将已构建应用的内容复制到$ ApacheLocation / webapps / angular

3)重写规则:

RewriteCond %{REQUEST_PATH} !-fRewriteRule ^/angular/(.*) /angular?path=$1

4)在app.component.ts上的设置导航:

constructor(private activatedRoute: ActivatedRoute, private router: Router) { }ngonInit() {const path = this.activatedRoute.snapshot.queryParams['path'];const navigateTo = '/' + path;if (path) {  this.router.navigate([navigateTo]);}

}

您可以在这里找到测试项目:https :
//github.com/avuletica/test

重写规则说明:

# %{REQUEST_PATH} corresponds to the full path that is used for mapping.# ! NOT character # '-f' (is regular file) Treats the TestString as a pathname and tests whether or not it exists, and is a regular file.# ^ matches the beginning of the string or line# . matches any charceter except line breaks# * match 0 or more of the preceding token

因此,基本上,如果在/ angular/anything上没有文件,tomcat会将完整路径作为查询字符串发送到angular应用程序,并且从该查询参数angular处理路由。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/369144.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号