spring-boot - 将 html、xhtml 渲染为 PDF 时图像 Thymeleaf 不显示
问题描述
我有一个 html 代码,我想将其导出为 pdf,当我使用 URL http://localhost:8080/files/downloadFile/ {id}调用的函数时, PDF中的图像不会出现,当我使用相同的 url (localhost:8080/) 但是当我调用另一个项目中托管的相同函数时从另一个项目调用该函数 (localhost: 8082 ) 它出现http://localhost:8082/files/downloadFile {id}这是我的html代码。
<div> ICI <img th:src="@{${pic}}">
<div>HESS
<img th:src="${pic}">
<img src="http://localhost:8080/files/downloadFile/bfd59122-592e-49f2-a951-41deeec62213">
<img src="http://localhost:8082/files/downloadFile/bfd59122-592e-49f2-a951-41deeec62213">
</div>
</div>
When parsing from html to pdf I display, the thymeleaf html code and it's presented like this.
<body >
<div class="container" >
<div>
<span>SS</span>
<div> ICI <img src="http://localhost:8080/files/downloadFile/bfd59122-592e-49f2-a951-41deeec62213">
<div>HESS
<img src="http://localhost:8080/files/downloadFile/bfd59122-592e-49f2-a951-41deeec62213">
<img src="http://localhost:8080/files/downloadFile/bfd59122-592e-49f2-a951-41deeec62213">
</div>
</div>
</div>
</div>
</body>
总结一下,当我从 localhost:8080 调用托管在localhost:8082但不在localhost :8080 中的方法时,src 工作正常。
另一句话,当我在浏览器中显示 Thymeleaf html 时,它工作正常。
解决方案
推荐阅读
- lua - 无法将客户端连接到代理
- laravel - .htaccess 文件中是否需要进行任何更改才能访问 API 路由?
- spring-boot - 部署在多个数据中心的基于 JMS 的 Spring Boot 微服务的最佳方法
- r - 使用分隔符加入列表中的列表
- android - 无法在 Flutter 上的地图上放置 json
- c# - Moq 抽象类方法结果
- jquery - 带有 2 行的 D3js 图表 - 仅显示行
- javascript - CSURF 在令牌写入错误时返回 EBADCSRFTOKEN
- git - git push 由于我不明白的原因被拒绝
- linux - 如何刷新部署在 Linux 机器上的应用程序