首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Freemarker中使用字符串列表

如何在Freemarker中使用字符串列表
EN

Stack Overflow用户
提问于 2015-07-10 20:00:11
回答 2查看 461关注 0票数 0

我试图使用一个行业列表来确定输出文本。例如,如果行业是分发&批发或eCommerce或制造显示一些文本,否则显示一些其他文本。

下面的代码有一些问题:

代码语言:javascript
复制
<#if (customer.custentity_esc_industry)=["Distribution \a Wholesale","eCommerce","Manufacturing"]>some text<#else>some other text</#if>

但是我似乎不能让它正常工作..。有什么想法吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-07-10 22:03:39

代码语言:javascript
复制
<#if ["Distribution \a Wholesale", "eCommerce", "Manufacturing"]
         ?seq_contains(customer.custentity_esc_industry)>
  some text
<#else>
  some other text
</#if>

甚至(?then需要2.3.23):

代码语言:javascript
复制
${["Distribution \a Wholesale", "eCommerce", "Manufacturing"]
  ?seq_contains(customer.custentity_esc_industry)
  ?then("some text", "some other text")}
票数 0
EN

Stack Overflow用户

发布于 2015-07-10 20:20:48

你可以这样做:

代码语言:javascript
复制
<#assign sequence = ["Distribution \a Wholesale","eCommerce","Manufacturing"] />
<#assign flag = 0 />
<#list sequence as seq>
     <#if customer.custentity_esc_industry == seq>
          <#assign flag =1>
          <#break />
     </#if>
</#list>
<#if flag == 1>
     //some text
<#else>
     //some other text
</#if>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31349315

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档