table 中的td 字段超长,超过部分用....表示

#contentTable{
table-layout:fixed;
}
.contentShort{
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
width:80px;
}

=======================================

<table id="contentTable"
class="table table-striped table-bordered table-condensed">

=======================================

<td class="contentShort">${mapData.title}</td>

=======================================

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你可以通过在模板使用Freemarker的自定义指令来实现在表格增加自定义字段。首先,你需要在Java代码定义一个Freemarker的自定义指令类,具体实现如下: ```java import java.io.IOException; import java.util.List; import java.util.Map; import freemarker.core.Environment; import freemarker.template.TemplateDirectiveBody; import freemarker.template.TemplateDirectiveModel; import freemarker.template.TemplateException; import freemarker.template.TemplateModel; import freemarker.template.TemplateModelException; import freemarker.template.utility.ObjectWrapper; public class CustomTableDirective implements TemplateDirectiveModel { @Override public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { // 获取表格数据 List<TableInfo> tableInfoList = (List<TableInfo>) env.getVariable("tableInfoList").getAsList(); // 获取自定义字段参数 String customField = params.get("customField").toString(); // 遍历表格数据,为每个表格添加自定义字段 for (TableInfo tableInfo : tableInfoList) { tableInfo.getFields().add(customField); } // 输出表格 body.render(env.getOut()); } } ``` 然后,在你的Freemarker模板添加以下代码: ```ftl <#assign customTableDirective = "com.example.CustomTableDirective"?new()> <#assign tableInfoList = configBuilder.getTableInfoList()> <@customTableDirective customField="customField"> <#list tableInfoList as table> <table> <thead> <tr> <#list table.getFields() as field> <th>${field}</th> </#list> </tr> </thead> <tbody> <#list table.getRows() as row> <tr> <#list table.getFields() as field> <td>${row[field]}</td> </#list> </tr> </#list> </tbody> </table> </#list> </@customTableDirective> ``` 这样,你就可以在表格添加自定义字段了。注意,这里假设你的表格数据是通过变量`tableInfoList`传递给模板的。如果你的表格数据来源不同,需要修改相应的代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值