我会使用thymeleaf 3模板引擎来包含外部/远程片段.
今天我正在尝试遵循语法
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Thymeleaf test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<div th:insert="http://localhost:5001/"></div>
<div th:insert="http://localhost:5002/"></div>
<div th:insert="http://localhost:5003/"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是有效的,但如果每个端口的每个服务花费2秒钟来响应,模板将至少在2 + 2 + 2 = 6秒后生成.
而我正在寻找更多异步/并行的东西,其中模板生成将是MAX(2,2,2)= 2秒(+/-生成其他东西的时间).
我没有找到任何内置的方法,但是如果你有任何关于我应该从哪里开始以及怎么做的话,我不会接近延长Thymeleaf 3.
PS:我知道有DataDriven功能,但我不是在寻找注入数据的异步方式,它实际上是处理模板的异步方式!