spring - 具有自己的 UI 和 Spring 和 Thymeleaf 的微服务

标签 spring thymeleaf microservices ssi

我有三个 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/

相关文章:

javascript - 如何在页面提交时自动滚动到页面顶部

spring-mvc - Thymeleaf 中两个日期之间的天数

java - 如何正确索引 @RequestMapping 中的路径(JsonNodeTree 的路径)?

amazon-web-services - 如何使用 AWS Beanstalk 和 Spring Cloud Netflix 在 Docker 容器之间建立连接

java - Spring STS初学者学习

java - 为什么 Spring 会从 Singleton 类创建 2 个对象?

java - Thymeleaf 中的模块化模板解析器

mysql - Thymeleaf 不显示来自 MySQL 的数据

java - 想要在jsp中显示与值对应的枚举名称

http - vert.x 请求 x-www-form-urlencoded 数组