【发布时间】:2019-09-23 15:13:12
【问题描述】:
我正在尝试通过在 Spring Boot 中使用带有 thymeleaf 作为视图引擎的 jquery append 函数来动态显示图像
这是我尝试将图像附加到 div ('.show-image') 的方式:
success: function (data) {
var image_url = "images.png";
var images_div = "<img th:src=\"@{/image/"+image_url+"}\" height=\"360px\" width=\"400px\">";
$('.show-image').append(images_div);
}
但是,它只显示空图像(没有 404 错误)
我尝试了其他随机在线图片和作品:
success: function (data) {
var images_div = "<img src=\"https://onlinejpgtools.com/someimage/random-grid.jpg\" height=\"360px\" width=\"400px\">";
$('.show-image').append(images_div);
}
当我静态显示图像时也可以(我认为没有路径问题):
<div class="show-image">
<img th:src="@{/image/images.png}" height="360px" width="400px">
</div>
有什么建议吗?
【问题讨论】:
标签: java jquery spring-boot thymeleaf