我正在尝试为sendind电子邮件开发spring boot应用程序.一切都还可以但是在模板百里香中,当我尝试添加图像时显示错误.这是我的template.html的片段
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title th:remove="all">Order Confirmation</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<div>
<h2 th:text="${title}">title</h2>
<p th:utext="${description}">
description
</p>
<br />
<br />
<br />
<p>Bien cordialement</p>
<div>
<img th:src="@{/img/signature.png}" />
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是错误:
ERROR [[/jira-rct/v1.0].[dispatcherServlet]] [http-nio-8080-exec-1] Servlet.service() for servlet [dispatcherServlet] in context with path [/jira-rct/v1.0] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateProcessingException: Link base "/img/crm-signature.png" cannot be context relative (/) or page relative unless you implement the org.thymeleaf.context.IWebContext interface (context is …Run Code Online (Sandbox Code Playgroud) 我在我的视图中使用spring-boot和thymeleaf作为模板开发了一个应用程序我尝试在循环中使用变量但是它没有用.这是我的代码片段:
<table >
<thead>
<tr>
<th>Type</th>
<th>Résumé</th>
<th>Contenu</th>
</tr>
</thead>
<tbody>
<tr th:each="subTask : ${lstOtherSubTasks}">
<td><img th:src="@{/img/icons/${subTask.issueTypeId}.png}" title="TODO" /> // here the variable ${subTask.issueTypeId} not works
<p th:text="${subTask.issueTypeId}" /> here the value of the variable ${subTask.issueTypeId} is not null I get the good value
</td>
<td th:text="${subTask.resume}"></td>
<td th:text="${subTask.contenu}"></td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)