zoukankan      html  css  js  c++  java
  • freemarker如何遍历HashMap

    查询资料有以下两种方法:

    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>

    但是需要在spring-mvc.xml文件里配置freemarkerSettings

    <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>
    而且这个配置成功之后 第一种方式是不可以的 第二种是可以成功显示的
  • 相关阅读:
    手势
    ios提示框,自动消失
    UITableView
    UIAlertView
    微信公众号主页链接
    试用avalon2.0
    VirtualPathProvider的使用
    代码暂存 [获取二唯码并识别保存二唯码]
    提交数据url太长导致提交失败
    打通前后台
  • 原文地址:https://www.cnblogs.com/xiaofeilee/p/4451558.html
Copyright © 2011-2022 走看看