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