我有三个 Web 应用程序微服务和一个包含 UI 的网关。因此,我想要做的是更改应用程序,每个微服务都有自己的 UI,并且网关应该包含服务器端。我使用 Thymeleaf 作为模板引擎并执行包含操作,如下所示:
<div th:replace="http://localhost:8080/#/organizations"></div>
我的问题是 CSS 和 JS 文件不是从原始 localhost:8080 服务器中包含的,而是从包含内容 localhost:9090 的服务器中包含的。
这就是我将 JS 和 CSS 文件包含在 *:8080:
<script th:src="@{webjars/jquery/$jquery.version$/jquery.min.js}"</script>
希望您理解我的问题并且有人可以帮助...
最佳答案
这个${#httpServletRequest.requestURL}成功了......
<link th:href="@{__${#httpServletRequest.requestURL}__webjars/bootstrap/?{bootstrap.version}/css/bootstrap.min.css}" rel="stylesheet" />
现在一切正常。
关于spring - 具有自己的 UI 和 Spring 和 Thymeleaf 的微服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35743527/