gpt4 book ai didi

Angularjs 应用程序刷新与 tomcat 转到 404 页面

转载 作者:行者123 更新时间:2023-11-28 23:25:45 25 4
gpt4 key购买 nike

我已经在 tomcat7 中部署了 Angular 应用程序。

做了什么:

      1 Made angular app as an html5 mode to true by adding  fallowing code in app.js

if (window.history && window.history.pushState) {
$locationProvider.html5Mode(true);
};



2. Added `<base href="/dist/#/">` in index.html

2. Build the app by using grunt `grunt build`

3. Kept the dist into the folder `TOMCAT_HOME/webapp/ROOT`

问题:

  1. When i refresh the page it show 404
2. When I copy the URL and paste then also it's giving 404 error.
3. Provide me link for tomcat configurations

注意:如果我用 Host/dist 访问浏览器,应用程序正在运行(如果我逐个州导航)。

请帮我看看我错在哪里。以及如何解决它(如果需要,使用 tomcat 服务器配置)。

我允许的 URL :

  1. Deploy AngularJS app on tomcat
  2. http://diveintohtml5.info/examples/history/fer.html
  3. Removing the fragment identifier from AngularJS urls (# symbol)

最佳答案

不确定您是否仍在寻找答案,但我会分享我的解决方案以备不时之需。

我所做的基本上是使用 http://tuckey.org/urlrewrite/并将规则设置为

<rule>
<from>^/search/$</from>
<to>index.html</to>
</rule>

我想指出,我使用的是实际文件名,而不是我想去的 url。

希望这对您有所帮助!

问候,

贝尔坎

关于Angularjs 应用程序刷新与 tomcat 转到 404 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37325052/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com