@Autowired private SpringTemplateEngine thymeleaf; public String aa() { Context context = new Context(); context.setVariable("xx1", "xx1"); return thymeleaf.process("templateName", context); }