FreeMarker Error : left-hand operand: Expected a hash, but this evaluated to a sequence

FreeMarker Error : left-hand operand: Expected a hash, but this evaluated to a sequence

Ask Question
up vote 2 down vote favorite

When I loop through a list in freemarker like below, it works fine.

<#list cModel.products as product>

But when I'm tring to assign the size of the list to a variable like,

 <#assign totalProducts = cModel.products.getList()?size>

I'm getting an exception from free marker like below

left-hand operand: Expected a hash, but this evaluated to a sequence

Any suggestions?

share improve this question
 
 
What is the signature of Product.getList()? Post the Java. –  Raedwald  Jul 27 '14 at 7:43

1 Answer

active oldest votes
up vote 5 down vote accepted

I Hope you've accessing it wrongly.

As per your example, the list name is product. So,

<#assign totalProducts = cModel.getProducts()?size>

Should return back the size of the products.

Hope it helps.

share improve this answer
 
 
Thanks for your reply. It resolved the issue. –  javaAnto  Jul 27 '14 at 13:25
1  
cModel.products?size is the nicer way of doing that. –  ddekany  Jul 27 '14 at 13:57 

你可能感兴趣的:(FreeMarker Error : left-hand operand: Expected a hash, but this evaluated to a sequence)