You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by "zhouyanming (JIRA)" <ji...@apache.org> on 2016/09/08 01:34:20 UTC
[jira] [Comment Edited] (FREEMARKER-33) <#list map as k,v> doesn't
works as expected
[ https://issues.apache.org/jira/browse/FREEMARKER-33?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15472369#comment-15472369 ]
zhouyanming edited comment on FREEMARKER-33 at 9/8/16 1:33 AM:
---------------------------------------------------------------
I find where the problem is:
{code:java}
package freemarker.ext.beans;
public class MapModel extends StringModel implements TemplateMethodModelEx {
@Override
protected Set keySet() {
Set set = super.keySet();
set.addAll(((Map) object).keySet());
return set;
}
}
{code}
Why not just return map.keySet() , does super.keySet() has any use case for a map? I think map?keys should not include method names such like "getClass hashCode"
was (Author: quaff):
I find where the problem is:
{code:java}
package freemarker.ext.beans;
public class MapModel extends StringModel implements TemplateMethodModelEx {
@Override
protected Set keySet() {
Set set = super.keySet();
set.addAll(((Map) object).keySet());
return set;
}
}
{code}
Why not just return map.keySet() , does super.keySet() has any meaning for a map? I think map?keys should not include method names such like "getClass hashCode"
> <#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)