application.properties是
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
# set to false for hot refresh, should be set to true in deployment
spring.thymeleaf.cache=false
获取模板内容是这样的:
@Autowired
private ITemplateResolver templateResolver;
private String getMailContent(EmailDTO email, EmailType type) {
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setTemplateResolver(templateResolver);
Context context = new Context(email.getLocale());
context.setVariable("email", email.getAddress());
return templateEngine.process("email/resetcontent", context);
}
模板是:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title>SIM : Reset Password</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
</head>
<body>
<span th:text="#{reset.password.title}">Reset Password</span>
<span th:text="${email}"></span>
</body>
</html>
th:text =“$ {email}”可以解析但是th:text =“#{reset.password.title}”是?? reset.password.title_en_US ??
谁能告诉我为什么?非常感谢你答案 0 :(得分:0)
如果您使用spring引导默认消息解析器,请尝试为具有“title”字段的“password”bean找到代码“reset”。
你应该使用这段代码:
<span th:text="#{resetPasswordTitle}">Reset Password</span>