80183053 2013-09-12
freemarker在解析数据格式的时候,自动默认将数字按3为分割(1,000),这个问题给操作带来一定的额外处理复杂度,解决方法有如下几种:
1、在模板中直接加.toString()转化数字为字符串,如:${languageList.id.toString()};
2、在freemarker配置文件freemarker.properties加<#setting number_format="#">或者 <#setting number_format="0">;
3、在模板中直接加<#setting number_format="#">或者<#setting number_format="0">,如:<#if AdminLanguagePaginationMsg?exists>
<#setting number_format="#">
2.怎么遍历输出(拿ArrayList举个例子)
1)在Action里把ArrayList放到值栈里
private ArrayList<PostBean> postList=new ArrayList<PostBean>();
session.put("postList", postList);
2)模板:
<#if Session["postList"]?exists>
<#list Session["postList"] as item>
${item.id} ${item.title}//其实item就是一个PostBean
</#list>
</#if>
http://wangbaoaiboy.blog.163.com/blog/static/5211191020109113384091/