【发布时间】:2021-01-06 14:45:34
【问题描述】:
我已经构建了一个 Spring Boot Web 应用程序。它托管在端口 80 上的 tomcat 服务器上。
为了从服务器动态加载图像,我使用的是 xampp 提供的 apache 服务器。所有图片都在 9090 端口访问。
在我的 Web 应用程序代码中,我在 url 中加载带有 localhost:9090 的图像,如下所示。
<img th:src="@{${'http://localhost:9090/COVID/DD/' + item.imageFileName}}" class="card-img-top rounded-0" />
问题:由于url路径是localhost,所以我使用服务器的公网ip查看web应用时,图片加载不出来。
如何在不将主机硬编码为localhost 的情况下从端口 9090 获取图像?
【问题讨论】:
标签: javascript html spring-boot