我想使用与车把或自由标记相同的胸腺
我想将胸腺用作简单的字符串解析器,例如车把,并做了一些代码,假定它会起作用
pom.xml
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>3.0.15.RELEASE</version>
</dependency>
代码
Map<String, Object> data = new HashMap<String, Object>();
data.put("name", "dickens");
data.put("age", "100");
TemplateEngine en = new TemplateEngine();
Context c = new Context(Locale.ENGLISH, data);
String p = en.process("Hello ${name} your age is ${age}", c);
System.out.println(p);
我所获得的输出,
Hello ${name} your age is ${age}
我希望它会打印hello dickens your dickens your code>
我不能放hello [[$ {name}]]您的年龄是[[$ {age}]]
这将是一个重大的变化,我可以启用任何标志字符串内联在所有位置?
I wanted to use Thymeleaf as simple string resolver like handlebars and did some code presuming it will work
pom.xml
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>3.0.15.RELEASE</version>
</dependency>
code
Map<String, Object> data = new HashMap<String, Object>();
data.put("name", "dickens");
data.put("age", "100");
TemplateEngine en = new TemplateEngine();
Context c = new Context(Locale.ENGLISH, data);
String p = en.process("Hello ${name} your age is ${age}", c);
System.out.println(p);
The output I am getting is
Hello ${name} your age is ${age}
I am expecting it will print Hello dickens your age is 100
I cannot to put Hello [[${name}]] your age is [[${age}]]
that will be a major change everywhere, Is there any flag that I can enable string inline all places?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要创建一个解析器:
You need to create a Resolver: