0
我使用Spring百里香發送豐富的郵件模板。春季Rich HTML郵件與百里香
我使用下面的java和html代碼。沒有得到任何錯誤,但$值沒有取代上下文值。我得到原始的html,因爲它在電子郵件中。我在這裏錯過了什麼嗎?
Java代碼:
final Context ctx = new Context();
ctx.setVariable("subject", "Welcome to App");
ctx.setVariable("name", fullName);
ctx.setVariable("userEmailId", email);
ctx.setVariable("activateLink", agentAddedUrl);
ctx.setVariable("dialrSupportEmail", dialrSupportEmail);
ctx.setVariable("dialerSupportNumber", dialrSupportPhone);
final String htmlContent = templateEngine.process("agentEmailTemplate.html", ctx);
System.out.println("HTML ==>>> "+htmlContent);
HTML,agentEmailTemplate.html,
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title th:text="${subject}">Welcome to TestApp</title>
<style type="text/css">
</style>
<script type="colorScheme" class="swatch active">
</script>
</head>
<body paddingwidth="0" paddingheight="0"
style="padding-top: 0; padding-bottom: 0; padding-top: 0; padding-bottom: 0; background-repeat: repeat; width: 100% !important; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; -webkit-font-smoothing: antialiased;"
offset="0" toppadding="0" leftpadding="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
class="tableContent bgBody" align="center"
style='font-family: Helvetica, Arial, serif;'>
<div class='movableContent'>
<table width="520" border="0" cellspacing="0" cellpadding="0"
align="center">
<tr>
<td align='left'>
<div class="contentEditableContainer contentTextEditable">
<div class="contentEditable" align='center'>
<p
style='text-align: left; color: #222222; font-size: 14px; font-weight: normal; line-height: 19px;'>
<br> Hi ${name},</br> <br> Your App Admin has
created an account for you.</br> <br> To sign up for
ContactCentral Account Agent Access,click here and create your
own password .Your username is ${userEmailId} . </br> <br> <br>
Have questions? Get in touch with us via ${dialrSupportEmail}
or call ${dialerSupportNumber}.</br>
</br> <br> <br> Cheers,</br>
</br> <br> <span style='color: #222222;'>App Accounts
Team</span></br>
</p>
</div>
</div>
</td>
</tr>
</table>
</div>
</table>
</body>
</html>
何我可以把鏈接裏面的href呢? Activate \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t your Account – user1578872
這是您可以在錨點打印表達式的方式 –