angularjs html 5 mode

angularjs html 5 mode

本文关键字:mode html angularjs      更新时间:2023-09-26

我正在使用angularjs和java tomcat。我有一个应用程序,她的基本 URL 是 myapplication/app/index.html当我在网址中使用#时,一切正常当我尝试切换到html 5模式时,它变得疯狂我添加了基本网址元标记,但在每个选项中都没有运气使用整个路径或没有<base href="index.html" />并将应用程序的配置设置为$locationProvider.html5Mode(true);似乎没有什么能帮助我任何想法?

应用代码 :

$locationProvider.html5Mode({ enabled: true, requireBase: false });

$locationProvider.html5Mode(true);

对于代码库,我尝试了所有内容

<base href="/" />

<base href="myappname/pathtofiles/" />

需要你的服务器总是返回index.html。为此,您可以使用,例如,快速服务器:http://www.seankenny.me/blog/2013/08/05/angularjs-in-html5-mode-with-expressjs/

如果你使用tomcat,

也许,其中一个解决方案对于服务器端重写url很有用(tomcat经常使用Apache Rewrites):https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode