Once you get familiar with FreeMarker, you will find certain subtletieswith it that may become frustrating. The most common thing you'll likely run in to is the BeansWrapper provided by FreeMarker. If you don't know what this is, don't worry. However, if you do, know this: app
The StrutsBeanWrapper extends the default FreeMarker BeansWrapper and provides almost no change in functionality, except for how it handles maps. Normally, FreeMarker has two modes of operation: either support for friendly map built-ins (?keys, ?values, etc) but only support for String keys; OR no special built-in support (ie: ?keys returns the methods on the map instead of the keys) but support for String and non-String keys alike. Struts provides an alternative implementation that gives us the best of both worlds. ide
It is possible that this special behavior may be confusing or can cause problems. Therefore, you can set the struts.freemarker.wrapper.altMap property in struts.properties to false, allowing the normal BeansWrapper logic to take place instead. ui
這裏大體的意思就是,freemarker關於map的處理方式有兩種,都是 使用freemarker內建的map?keys this
我之前只是使用map?keys返回 這個map當中全部的key的列表, spa
struts提供了<constant name="struts.freemarker.wrapper.altMap" value="false"/> 參數供咱們設置: orm
當值爲true的時候,map?keys返回 map中key的列表 不(這時候map的key只能是String類型的)。當值設置爲fase的時候,map?keys返回的是map這個類的全部方法和內容,例如map?keys?size返回22,由於map有22個方法。也能夠使用 ci
此時(map的key能夠是string或者不是string類型的) get