简体   繁体   中英

How to render java.util.Collection using Playframework template engine?

I just want to render a simple list. I followed official documentation but IntelliJ is showing an error. This is the code to display a ul list:

@import java.util 
@(products: util.Collection[String])
 <ul> 
 @for(product <- products) 
 { 
   <li>product</li>  
 } 
 </ul> 

Could you please tell what I am doing wrong?

Firstly, does it compile in sbt? The IDE may be wrong. Secondly, have you enabled the PlayJava sbt plugin, or the PlayScala? When enabling PlayJava, some extra imports are added to templates to convert Java collections to Scala collections. Finally, have you tried using java.util.List ? I'm not sure if the imports include something to convert Collection to a Scala Seq.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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