【问题标题】:How to set an img on html page in my java project如何在我的 java 项目中的 html 页面上设置 img
【发布时间】:2022-07-23 00:38:20
【问题描述】:

我是学生,我尝试将图像放到测试站点。 但有些不对劲。我不知道是什么。 我为我的“资源”目录尝试了很多 URL 或更改位置

但它不起作用。 mb 有人能找出错误吗?

代码:

<!DOCTYPE html>
<html lang="en" xmlns:th="http://thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>Все люди</title>
</head>
<body>

<div th:each="person : ${people}">
  <a th:href="@{/people/{id}(id=${person.getId()})}"
     th:text="${person.getName() + ', ' + person.getAge() + ', ' + person.getEmail()}">user</a>
</div>
<br>
<hr>
<a href="/people/new">New person</a>
<a href="/people/createtestdb">Add more rows</a>
<br>
<div>
  <img src="/1650622351952.jpg"/>
</div>
</body>
</html>

My project structure nowdPP.png

【问题讨论】:

  • 如果它与 html 位于同一目录中(并且不应该),您是否尝试过 &lt;img src="1650622351952.jpg"/&gt;

标签: java html image


【解决方案1】:

您需要提供图像的文件路径,而不仅仅是图像名称。

【讨论】:

    猜你喜欢
    • 2013-05-08
    • 2018-11-23
    • 1970-01-01
    • 2020-01-11
    • 1970-01-01
    • 1970-01-01
    • 2014-10-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多