@(工作笔记)
freemarker-record
[TOC]
freemarker 处理 HashMap()
真是大坑啊。。。
在freemarker中无法通过Integer获取value所有必须将key转换成String
如:HashMap
如果存的数据是int类型在数据后面添加一个 ( +“” )将数据转换成String类型
代码如下:
后台java代码:Map<String,String> _mapList = new HashMap<String, String>();
html代码:
<#list _mapList?keys as key>
<option value="${key}">_mapList[key]</option>
</#list>
How to configure the freemarker template path or what's the default path?
Thanks, after some research, I find an official solution with Intellij Idea 2017.2 Ultimate version.
\1. find a red warning , for example ,
<#include "/common/global.ftl" />
use " OPTION + Enter (Mac OSX)" , will popup a windows, just following the step:
\2. choose "Define template root in comment (global)
it will create a new file, under "/src/main/resources" , filename is freemarker_implicit.ftl , update the path by your setting
[#ftl]``[#-- @implicitly included --]``[#-- @ftlroot "../webapp/WEB-INF/pages" --]
3. if need, use File -> Invalidate Caches/Restart
4. use it . just like
<#include "/common/header.ftl" />