【发布时间】:2016-12-17 10:58:23
【问题描述】:
我正在使用 Spring Boot 1.4.0.M2、Angular 1.5.8、Angular UI Router 0.3.1 和 Thymeleaf 模板。
我想要做的是从我的网址中删除哈希 # 我想要这样的东西:
http://localhost:8080/#/contact
看起来像这样
我做了什么:
-
添加到我的 angular configuration.js 文件中,如下所示:
$locationProvider.html5Mode(true); $locationProvider.hashPrefix('!'); -
添加到我的 userIndex.html 头
base href="/userIndex.html"/>
这个 userIndex.html 包含所有 js 库,这是我的单页索引页面,它包含这样的导入:
<script type="text/javascript" th:src="@{/js/lib/jquery.min.js}" />
和 UI 路由器:
<div ui-view="" class="ui-container"></div>
在这个哈希 # 从 URL 中消失之后,但是!
我打开我的网页http://localhost:8080/,然后单击链接到例如“/contact”,然后转到子页面 URL 看起来很完美http://localhost:8080/contact 没有哈希,页面看起来像这样。
当我按 F5 重新加载网页 http://localhost:8080/contact 时,内容看起来像这样:
从http://localhost:8080/ 开始并单击链接到 /contact 使一切正常,尝试输入 URL http://localhost:8080/contact 呈现没有 css、js 等的原始 html。未加载 userIndex.html 是否可以将其加载到子页面,如/联系方式?
这就是我的项目和模板配置的样子
这里有没有人可以帮我解决这个重载问题?也许是我的 Spring Boot 模板配置有问题?
【问题讨论】:
标签: angularjs spring spring-mvc spring-boot