Freemarker获取pojo属性

获取pojo属性

${key.property}
通过点,获取属性

数据集

//6.创建一个数据集,可以是pojo也可以是map,推荐使用map
Map data = new HashMap<>();
Student student = new Student(1, "小米", 11, "北京昌平回龙观");
data.put("student", student);

模板

<html>
<head>
    <title>测试页面</title>
</head>
<body>
    学生信息:<br>
    学号:${student.id}<br>
    姓名:${student.name}<br>
    年龄:${student.age}<br>
    家庭住址:${student.address}<br>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/nangeali/article/details/81807345