我正在进行密码重置功能,为此,我使用百万美元模板。但这是我的简单html,它不会呈现。这告诉我下面的错误:
There was an unexpected error (type=Internal Server Error, status=500).
Exception parsing document: template="demo", line 10 - column
我的百里香配置
@Bean
public ClassLoaderTemplateResolver emailTemplateResolver(){
ClassLoaderTemplateResolver emailTemplateResolver = new ClassLoaderTemplateResolver();
emailTemplateResolver.setPrefix("templates/mail/");
emailTemplateResolver.setSuffix(".html");
emailTemplateResolver.setTemplateMode("HTML5");
emailTemplateResolver.setCharacterEncoding("UTF-8");
emailTemplateResolver.setOrder(1);
return emailTemplateResolver;
}
我的demo.html是
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<form th:action="@{/resetpassword(_key=${resetPasswordToken})}" method="post">
<div>
<input type="password" th:field="*{password}">
<input type="password">
</div>
</form>
</body>
</html>
我的控制器是
@RequestMapping(value = "/resetpassword", method = RequestMethod.GET)
public String resetpasswordView( @RequestParam(value = "_key") String resetPasswordToken, final Model model) {
System.out.println(resetPasswordToken);
model.addAttribute("resetPasswordToken", resetPasswordToken);
return "demo";
}
我认为这是非常简单的HTML,它应该是渲染的。所以,请帮助我,我在这里缺少什么?
由于
答案 0 :(得分:6)
默认情况下,Thymeleaf要求您的模板是有效的XML。您尚未关闭AutoResizingMask
代码,因此当它在第10行到达mymap.autoresizingMask = [UIViewAutoresizing.FlexibleWidth, UIViewAutoresizing.FlexibleHeight]
时,由于代码不平衡而失败。
您可以通过关闭代码解决问题:
<input>
或者,您可以使用Thymeleaf的遗留HTML5模式,但需要更多设置。