java - Thymeleaf Template Engine do not follow the expression language -


spring boot maven dependency

<dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-thymeleaf</artifactid> </dependency>  @service public class mailcontentbuilder {  private templateengine templateengine;  @autowired public mailcontentbuilder(templateengine templateengine){     this.templateengine=templateengine; }  public string build(string templatename,string user,string email) throws ioexception{     context context=new context();     context.setvariable("user", "alpha");     context.setvariable("email", "alpha@gmail.com");     string test=templateengine.process(templatename, context);     return test; } } 

this mail sender method.

mimemessage mimemessage=javamailsender.createmimemessage();     //mimemessage.setcontent(mailcontentbuilder.build("changepassword","alpha","ema il@email.com"), "text/html");      mimemessagehelper helper=new mimemessagehelper(mimemessage);     helper.setto(auth0userservice.getuser(userid).getemail());     helper.setfrom(fromusername);      helper.setsubject("password change confirmation");     helper.settext(mailcontentbuilder.build("changepassword","alpha","email@email.com"), true);     javamailsender.send(mimemessage); 

this template, in src/resources/templates

<!doctype html> <html xmlns:th="http://www.thymeleaf.org"> <head>   <meta http-equiv="content-type" content="text/html; charset=utf-8" />   <meta name="viewport" content="width=device-width, initial-scale=1.0" />   <title>change password</title>    </head>  <body > helloooo th:text="${user}"  </body>  </html> 

this sends, not follow expression language, writes page is. no use of variables.

helloooo th:text="${user}" 

th:text has attribute html tag, like

<p th:text="helloooo ${user}" /> 

should work, judging glance @ http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#using-texts


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -