我有一个spring mvc应用程序,我试图将一个日期LocalDate渲染成一个字符串,对于普通的视图它可以工作,但对于电子邮件它不起作用并抛出以下错误:
引起:org.springframework.core.convert.ConverterNotFoundException:找不到能够从类型[java.time.LocalDate]转换为类型[java.lang.String]的转换器
码:
import org.thymeleaf.context.Context;
import org.thymeleaf.spring4.SpringTemplateEngine;
@Service
public class EmailService {
@Autowired
private SpringTemplateEngine templateEngine;
public String prepareTemplate() {
// ...
Context context = new Context();
this.templateEngine.process(template, context);
}
}
Run Code Online (Sandbox Code Playgroud)