[英]Angular routing not working when deployed to tomcat 9 (Ubuntu 18.04)
[英]angular2 routing not working when you deployed dist folder onto tomcat server
我在prj-routing-final项目中使用ng-build --prod --aot
命令用angular-cli生成了dist文件夹,并将其部署到tomcat服务器上。 我能够导航到所有路由http://localhost:8081/dist/
并查看它们而无需重新加载。 如果我导航到http://localhost:8081/dist/recipes/0
并重新加载页面,则会出现此错误
HTTP Status 404 – Not Found
Type Status Report
Message /dist/recipes/0
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/8.5.14
如果我与ng serve
一起使用,我没有任何错误。 我能够导航到所有路线,重新加载页面,来回移动。
我还尝试使用https://www.npmjs.com/package/http-server中可用的Http-server来提供dist服务,重新加载后出现相同的错误。 No webpage was found for the web address: http://localhost:8080/recipes/0
我项目的 No webpage was found for the web address: http://localhost:8080/recipes/0
GitHub存储库
请帮助我。
您将需要配置您的Web服务器,以将所有未知(404)请求重定向到index.html,这将允许Angular应用程序随后将您的用户路由到所需的路由/视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.