还是用SSH框架,前台用freemaker遍历的一个数组list,代码如下:
<#list accountList as account>
<tr  
<td>${account_index+1}</td>
<td>${account.accNumber}</td>
<td>${account.name}</td>
<td>${account.createDate}</td><!--(date类型)-->
<td>${account.re}</td>
<td>${account.currencyid}</td>
<td>${account.company}</td></tr>
</#list>
其中的createDate为date类型数据,但是遍历出来的是一个String,格式为2010-10-10,也没有什么年月日,很空,听他们说freemaker中有个调用date类型的方法,哪位大侠给说说咯,谢谢啦!

解决方案 »

  1.   

    为什么查询出来的时候不todate()一下呢....这样好控制
      

  2.   

         FreeMarker支持date、time、datetime三种类型,这三种类型的值无法直接指定,通常需要借助字符串的date、time、datetime三个内建函数进行转换才可以
               <#assign test1 = "2009-01-22"?date("yyyy-MM-dd") />;
               <#assign test2 ="16:34:43"?time("HH:mm:ss") />
               <#assign test2 = "2009-01-22 17:23:45"?datetime("yyyy-MM-dd HH:mm:ss") />
               ${test1?string.full}
      

  3.   


    UP!或者是在后台用MAP取值的时候转换一下也可以。楼上的高手。
      

  4.   

    高手们,我现在修改代码如下:
    <#list accountList as account>
    <#assign test = ${account.createDate}?date("YYYY-MM-DD") />;
    <tr >
    <td>${account_index+1}</td>
                    <td>${account.accNumber}</td>
    <td>${account.name}</td>
    <td>${test?string.full}</td>
    <td>${account.re}</td>
    <td>${account.currencyid}</td>
    <td>${account.company}</td>
    </#list>
    这样对么?直接报错啊~~
      

  5.   

    搞定了,是yyyy-MM-dd,不是YYYY-MM-DD,非常感谢!!!!