1. \r\n示例一輸出結(jié)果:\r\n

        \r\n<#-- if指令的用法-->\r\n<#-- 在指令標(biāo)籤內(nèi)直接使用變量名得到文本值-->\r\n<#if flag == 1>\r\n    flag = 1\r\n<#elseif flag ==2>\r\n    flag = 2\r\n<#else>\r\n    <#-- 在指令標(biāo)籤外使用   ${變量名}   的格式來得到文本值-->\r\n    flag!=1 && flag!=2 flag的值為:${flag}\r\n<\/#if>\r\n<\/p>\r\n

        ----------------------------------------------------------<\/p>\r\n示例二輸出結(jié)果:\r\n

        \r\n<#-- 判斷變量是否存在-->\r\n<#if noExistList??>\r\n    List存在\r\n<#else>\r\n    List不存在\r\n<\/#if>\r\n<\/p>\r\n

        ----------------------------------------------------------<\/p>\r\n示例三輸出結(jié)果:\r\n

        \r\n<#-- list指令的用法,as可設(shè)置別名-->\r\n<#list strList as sl>\r\n    <#-- 在變量名后加   _index   得到變量在容器中的序號,從0開始-->\r\n    <#if sl_index == 0>\r\n        我的博客地址是:${sl}\r\n    <#else>\r\n        ${sl}\r\n    <\/#if>\r\n<\/#list>\r\n<\/p>\r\n

        <\/p>\r\n直接使用下標(biāo)訪問List:${strList[0]}${strList[1]}${strList[2]}\r\n<\/p>\r\n

        ----------------------------------------------------------<\/p>\r\n示例四輸出結(jié)果:\r\n

        \r\n<#-- 使用    ${變量名.變量名}   獲取容器對象的子對象-->\r\n${strMap.mapKey0}${strMap.mapKey1}${strMap.mapKey2}\r\n<\/p>\r\n

        ----------------------------------------------------------<\/p>\r\n示例五輸出結(jié)果:\r\n

        \r\n<#-- 當(dāng)變量是日期對象時,可使用函數(shù)使其按格式輸出-->\r\n${nowTime?string(\"yyyy-MM-dd\")}\r\n<\/p>\r\n<\/body>\r\n<\/html><\/pre>

        3??. ?? ? ???

        Tomcat? ????? ???? ????, ????? http:\/\/localhost:8080\/??? ???? ??\/helloWorld.htm
        ??? Freemarker ?? ??? ?????. ??? ??? ??? ?? ?? PHP ??? ????? ??????! <\/p>"}

        国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

        ? php教程 PHP開發(fā) Freemarker ?? ??? ?? ?

        Freemarker ?? ??? ?? ?

        Jan 05, 2017 pm 01:53 PM
        freemarker

        ? ?? ??
        ?????: springmvc+freemarker
        ?? ??: springsource-tool-suite-2.9.0
        JDK ??: 1.6.0_29
        tomcat ??: apache-tomcat-7.0 . 26

        step1. ???? ??? ?????.

        package www.asuan.com.controller;
        import java.util.ArrayList;
        import java.util.Date;
        import java.util.HashMap;
        import java.util.List;
        import java.util.Map;
        import org.springframework.stereotype.Controller;
        import org.springframework.ui.Model;
        import org.springframework.web.bind.annotation.RequestMapping;
        @Controller
        public class HelloWorldController {
            @RequestMapping("/helloWorld")
            public String helloWorld(Model model) {
                // 示例一
                int flag = 0;
                model.addAttribute("flag", flag);
                // 示例二
                List<String> noExistList = new ArrayList<String>();
                noExistList = null;
                model.addAttribute("noExistList", noExistList);
                // 示例三
                List<String> strList = new ArrayList<String>();
                strList.add("www.");
                strList.add("cnblogs.");
                strList.add("com/sunang");
                model.addAttribute("strList", strList);
                // 示例四
                Map<String, String> strMap = new HashMap<String, String>();
                strMap.put("mapKey0", "www.");
                strMap.put("mapKey1", "cnblogs.");
                strMap.put("mapKey2", "com/sunang");
                model.addAttribute("strMap", strMap);
                // 示例五
                Date nowTime = new Date();
                model.addAttribute("nowTime", nowTime);//傳輸時間對象
                return "helloWorld.ftl";
            }
        }

        step2.ftl ??? ?????.

        <html>
        <body>
        示例一輸出結(jié)果:
        <p>
        <#-- if指令的用法-->
        <#-- 在指令標(biāo)籤內(nèi)直接使用變量名得到文本值-->
        <#if flag == 1>
            flag = 1
        <#elseif flag ==2>
            flag = 2
        <#else>
            <#-- 在指令標(biāo)籤外使用   ${變量名}   的格式來得到文本值-->
            flag!=1 && flag!=2 flag的值為:${flag}
        </#if>
        </p>
        <p>----------------------------------------------------------</p>
        示例二輸出結(jié)果:
        <p>
        <#-- 判斷變量是否存在-->
        <#if noExistList??>
            List存在
        <#else>
            List不存在
        </#if>
        </p>
        <p>----------------------------------------------------------</p>
        示例三輸出結(jié)果:
        <p>
        <#-- list指令的用法,as可設(shè)置別名-->
        <#list strList as sl>
            <#-- 在變量名后加   _index   得到變量在容器中的序號,從0開始-->
            <#if sl_index == 0>
                我的博客地址是:${sl}
            <#else>
                ${sl}
            </#if>
        </#list>
        </p>
        <p><p></p>
        直接使用下標(biāo)訪問List:${strList[0]}${strList[1]}${strList[2]}
        </p>
        <p>----------------------------------------------------------</p>
        示例四輸出結(jié)果:
        <p>
        <#-- 使用    ${變量名.變量名}   獲取容器對象的子對象-->
        ${strMap.mapKey0}${strMap.mapKey1}${strMap.mapKey2}
        </p>
        <p>----------------------------------------------------------</p>
        示例五輸出結(jié)果:
        <p>
        <#-- 當(dāng)變量是日期對象時,可使用函數(shù)使其按格式輸出-->
        ${nowTime?string("yyyy-MM-dd")}
        </p>
        </body>
        </html>

        3??. ?? ? ???

        Tomcat? ????? ???? ????, ????? http://localhost:8080/??? ???? ??/helloWorld.htm
        ??? Freemarker ?? ??? ?????. ??? ??? ??? ?? ?? PHP ??? ????? ??????!

        ? ????? ??
        ? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

        ? AI ??

        Undresser.AI Undress

        Undresser.AI Undress

        ???? ?? ??? ??? ?? AI ?? ?

        AI Clothes Remover

        AI Clothes Remover

        ???? ?? ???? ??? AI ?????.

        Video Face Swap

        Video Face Swap

        ??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

        ???

        ??? ??

        ???++7.3.1

        ???++7.3.1

        ???? ?? ?? ?? ???

        SublimeText3 ??? ??

        SublimeText3 ??? ??

        ??? ??, ???? ?? ????.

        ???? 13.0.1 ???

        ???? 13.0.1 ???

        ??? PHP ?? ?? ??

        ???? CS6

        ???? CS6

        ??? ? ?? ??

        SublimeText3 Mac ??

        SublimeText3 Mac ??

        ? ??? ?? ?? ?????(SublimeText3)

        ???

        ??? ??

        ??? ????
        1601
        29
        PHP ????
        1502
        276
        ???