freemarker list用法

本文介绍了一种后端数据组织方式,使用Map和List结构存储和传递数据,前端通过模板引擎根据后端提供的数据动态生成表格,展示搜索词、类别、城市等信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 后端数据组织

  Map<String, Object> map = new HashMap<>();
 List<TopnItem> topnItems = iTopnService.getTopn(jobId, "home");
map.put("topn", topnItems.subList(0, 10));

 前端根据map中的key:topn获取数据

<tr bgcolor="#FFFFFF">

        <th style="font-family: '宋体', Arial; font-size: 14px; line-height: 36px;" align="center"> &nbsp;搜索词</th>
        <th style="font-family: '宋体', Arial; font-size: 14px; line-height: 36px;" align="center"> &nbsp;类别</th>
        <th style="font-family: '宋体', Arial; font-size: 14px; line-height: 36px;" align="center"> &nbsp;城市</th>
        <th style="font-family: '宋体', Arial; font-size: 14px; line-height: 36px;" align="center"> &nbsp;重复率/匹配度</th>
        <th style="font-family: '宋体', Arial; font-size: 14px; line-height: 36px;" align="center"> &nbsp;搜索次数</th>
        <th style="font-family: '宋体', Arial; font-size: 14px; line-height: 36px;" align="center"> &nbsp;词性分析</th>
        <#if topn?? && (topn?size > 0)>
            <#list topn as lender>
                <tr>
                    <td style="font-family: '宋体', Arial; font-size: 12px; line-height: 36px;" align="center" width="15%">&nbsp;${lender.keyword!""}</td>
                    <td style="font-family: '宋体', Arial; font-size: 12px; line-height: 36px;" align="center" width="15%"> &nbsp;${lender.category!""}</td>
                    <td style="font-family: '宋体', Arial; font-size: 12px; line-height: 36px;" align="center" width="15%">&nbsp;${lender.localname!""}</td>
                    <td style="font-family: '宋体', Arial; font-size: 12px; line-height: 36px;" align="center"><a href="${topnUrl}/${lender.jobIdString}/${lender.idString}">${lender.repeatDtail!""}</a></td>
                    <td style="font-family: '宋体', Arial; font-size: 12px; line-height: 36px;" align="center" width="15%">&nbsp;${lender.searchNum!""}</td>
                    <td style="font-family: '宋体', Arial; font-size: 12px; line-height: 36px;" align="center" width="15%">&nbsp;${lender.keywordCategorys!"暂无"}</td>
                </tr>
            </#list>
        <#else>
        </#if>
    </tr>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值