How freemarker traverses HashMap and freemarkerhashmap
You can query data in either of the following ways:
1,
<# If appMap? Exists>
<# List appMap? Keys as key>
Key: $ {key}
Value: $ {appMap. get (key )}
</# List>
</# If>
2,
<# List testMap. keySet () as testKey>
<Option value = "$ {testKey}">
$ {TestMap. get (testKey )}
</Option>
</# List>
But you need to configure freemarkerSettings in the spring-mvc.xml File
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/view/"/>
<property name="freemarkerSettings">
<props>
<prop key="object_wrapper">freemarker.ext.beans.BeansWrapper</prop>
</props>
</property>
</Bean>
In addition, after the configuration is successful, the first method is not allowed. The second method is displayed successfully.