我在Angular 5中开发了一个包含Routing
的应用程序,我用ng build --base-href /myApp/ --prod
构建了它。现在我想将它部署在我的笔记本电脑上运行本地的tomcat服务器上。
问题是,每当我在浏览器中重新加载我的应用程序页面时,我都会收到错误:
404请求的资源不可用
我在互联网上搜索解决策略,但我发现的任何东西都没有帮助我。我很确定我必须声明一些Rewrite rules
,但我不知道它们应该是什么样子以及我必须在哪里声明它们。
有谁知道如何解决这个问题?提前致谢。
也许您需要WEB-INF目录中的web.xml条目将所有未知URL重定向到您的默认index.html
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>My Angular Application</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<error-page>
<error-code>404</error-code>
<location>/index.html</location>
</error-page>
<error-page>
<error-code>410</error-code>
<location>/index.html</location>
</error-page>
</web-app>