How freemarker traverses HashMap and freemarkerhashmap

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.