[ 
https://issues.apache.org/jira/browse/FREEMARKER-33?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15462887#comment-15462887
 ] 

Daniel Dekany commented on FREEMARKER-33:
-----------------------------------------

That's not the mistake of `#list`, the data-model is indeed like that. Of 
course you don't want a data-model like that. This usually happens when a 
`BeansWrapper` is used to wrap the objects as opposed to its subclass, 
`DefaultObjectWrapper` (which is the default), and its `simpleMapWrapper` 
property was not set to `true` from its default, which is `false` 
unfortunately. If you can't change that in your application (like I'm not 
sureif you can do that under Struts), you can't use this variation of `#list`, 
instead you have to use the Java API, like `#list map.entrySet() as mapEntry`. 
Also, you are dealing with statics here, so it also matters if with what object 
wrapper was `statics` created.

> <#list map as k,v> doesn't works as expected
> --------------------------------------------
>
>                 Key: FREEMARKER-33
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-33
>             Project: Apache Freemarker
>          Issue Type: Bug
>          Components: engine
>    Affects Versions: 2.3.25-incubating
>            Reporter: zhouyanming
>             Fix For: 2.3.26-incubating
>
>
> {code:java}
> package test;
> import java.util.HashMap;
> import java.util.Map;
> public class MapFactory {
>       public static Map<String, String> create() {
>               Map<String, String> map = new HashMap<>();
>               map.put("mykey", "myvalue");
>               return map;
>       }
> }
> {code}
> {code:html}
> <#list statics['test.MapFactory'].create() as k,v>
> ${k}
> </#list>
> {code}
> I am expecting "mykey" only, but it render others like "getClass values .." 
> also.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to