10 |
11 | freemarker模版引擎:${name} |
12 |
13 |
14 | 输出对象属性值: |
15 | name:${people.getName()} |
16 |
17 |
18 | petName:${people.getPetName()} |
19 |
20 |
21 | 返回字符串长度 |
22 | name长度:${people.getName()?length} |
23 |
24 |
25 | 输出集合遍历: |
26 |
27 | <#list people.getType() as type>${type} #list>
28 | |
29 |
30 |
31 | 输出map属性: |
32 |
33 | ${people.getUser().username}
34 | ${people.getUser()['password']?c}
35 | |
36 |
37 |
38 | 算术运算符: |
39 |
40 | 直接运算:${1+2}
41 | 获取数据后再进行运算:${people.getAge() + 10}
42 | |
43 |
44 |
45 | 比较运算符: |
46 |
47 | 直接运算:<#if 1 gt 2>true<#else>false#if>
48 | |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/spring-boot-02-templateEngines/spring-boot-freemarker/src/test/java/com/louis/springbootfreemark/SpringBootFreemarkApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.louis.springbootfreemark;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class SpringBootFreemarkApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/spring-boot-02-templateEngines/spring-boot-thymeleaf/pom.xml:
--------------------------------------------------------------------------------
1 |