您的位置:首页 > 编程语言 > Lua

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

2017-03-07 14:44 9573 查看


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

Ask
Question






up
vote2down
votefavorite

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
11ca5
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?

freemarker
shareimprove
this question
asked Jul 27 '14 at 2:19





javaAnto
5317

 
 
What is the signature of 
Product.getList()
?
Post the Java. – Raedwald Jul
27 '14 at 7:43
add
a comment


1 Answer

activeoldestvotes

up vote5down
voteaccepted
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.

shareimprove
this answer
answered Jul 27 '14 at 13:18





Charles
662

 
 
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 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐