我正在尝试将javascript添加到电子邮件模板中,我的电子邮件模板是
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="ISO-8859-1"></meta>
<title>Insert title here</title>
</head>
<body>
<p id="demo">JavaScript can change the style of an HTML element.</p>
<script>
function myFunction() {
var x = document.getElementById("demo");
x.style.fontSize = "25px";
x.style.color = "red";
}
</script>
<button type="button" onclick="myFunction()">Click Me!</button>
<div class="mail">
<p th:text="#{greeting(${name})}"> Hello, Peter Static</p>
<div>
<p th:utext="#{username(${userNamr})}">name</p>
</div>
<div>
<p th:utext="#{password(${password})}">name</p>
</div>
</div>
</body>
</html>
在我的控制器中 我正在使用上下文对象设置变量,我使用mimemessage发送邮件我的问题是邮件部分工作正常但javascript部分无法正常工作
public String registrationHandler(HttpServletRequest request,final Locale locale,Model model) throws Exception {
final Context ctx = new Context(locale);
ctx.setVariable("name", "vignesh");
ctx.setVariable("userNamr", request.getParameter("name"));
ctx.setVariable("password", request.getParameter("password"));
final MimeMessage mimeMessage = this.mailSender.createMimeMessage();
final MimeMessageHelper message = new MimeMessageHelper(mimeMessage, true, "UTF-8"); // true = multipart
message.setSubject("User Name And Password");
message.setFrom("info@example.com");
message.setTo(request.getParameter("email"));
final String htmlContent = this.templateEngine.process("mailTemplate.html", ctx);
message.setText(htmlContent, true /* isHtml */);
this.mailSender.send(mimeMessage);
model.addAttribute("mail", request.getParameter("email"));
return "registrationSucess";
}
我只是想知道如何通过百科全书启用电子邮件模板中的javascript代码。