简体   繁体   English

如何使用freemarker拆分哈希图的值?

[英]How to split a value of a hashmap with freemarker?

I have a hash map as below : 我有一个哈希图,如下所示:

gfpFileBean.getChaines().put("IN-RDU", "GFPZ001Q;OK" );     
gfpFileBean.getChaines().put("IN-PLEIADES", "GFPZ003Q;OK" );

My Freemarker template is : 我的Freemarker模板是:

<#list gfpVb.chaines as key,value> 
                   <td>
                   <strong>${key}</strong>                                
                   </td>
                   <td>
                   <strong>${value}</strong>
</#list>

I would like to know if it is possible to split the value of hashmap with freemarker, to display the value where I want it in the table. 我想知道是否可以用freemarker拆分hashmap的值,以在表中的所需位置显示该值。

You can split a value to a list of values with someValue?split(someSeparator) , so: 您可以使用someValue?split(someSeparator)将值拆分为值列表。

<#list gfpVb.chaines as key, value> 
  <td>
    <strong>${key}</strong>                                
  </td>
  <#list value?split(';') as columnValue>
    <td>
      <strong>${columnValue}</strong>
    </td>
  </#list>
</#list>

But it's generally better practice to ensure that the value is already split in the data-model. 但是,通常最好的做法是确保已在数据模型中拆分值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM