内建函数语法格式: 变量+?+函数名称
获取集合大小和索引
- size函数
- index函数
public static void main(String[] args) throws IOException, TemplateException {
//1.创建一个配置对象
Configuration configuration=new Configuration(Configuration.getVersion());
//2.设置模板所在的目录
configuration.setDirectoryForTemplateLoading(new File("D:\\pinyougou\\freemarkerDemo\\src\\main\\resources"));
//3.设置字符集
configuration.setDefaultEncoding("utf-8");
//4.获取模板对象
Template template = configuration.getTemplate("test2.ftl");
//5.创建数据模型(可以是对象,也可以是map)
Map map=new HashMap();
List goodsList=new ArrayList();
Map goods1=new HashMap();
goods1.put("name", "苹果");
goods1.put("price", 5.8);
Map goods2=new HashMap(