小编Rej*_*eri的帖子

Thymeleaf电子邮件模板和ConversionService

我有一个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)

java spring spring-mvc thymeleaf spring-boot

3
推荐指数
1
解决办法
476
查看次数

标签 统计

java ×1

spring ×1

spring-boot ×1

spring-mvc ×1

thymeleaf ×1