添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
爱喝酒的香槟  ·  兔玩映画·  2 周前    · 
任性的弓箭  ·  php转html_html转php_php ...·  2 月前    · 
酒量大的香烟  ·  Samsung Galaxy S10 vs ...·  5 月前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

From my java code I'm returning a Set<String> . The view needs to check if the Set contains a specific string.. I can't find any docs on how Freemarker can handle this.
Any idea?

You can use seq_contains . You need FreeMarker 2.3.1

${x?seq_contains("blue")?string("yes", "no")}

This will output yes if the sequence contains "blue".

And from the comments, if you want this in an if statement

<#if x?seq_contains("myString")>

Here is the doco about it Built-ins for sequences

I think the answer could be corrected to have <#if mySet?seq_contains("myString")> because there was not specified that printing a string is required Also just <#if x.contains("myString")> should work – skrii Jul 11, 2016 at 14:20 I've added the if example. The point of the first example is to make it clear what seq_contains does, I wasn't trying to show all the various statements in which you can use it. – Iain Aug 14, 2016 at 0:24

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.