• freemarker 前端 判读 遍历 取值


    <#if content?length gt 100>
         ${content[0..100]}...
    <#else>
          ${content}
    </#if>
    

    freemarker里面不能包含><  所以要用到大于和小于,就要用gt,lt gt是大于,lt是小于, >= gte , <= lte

    private Map<Integer,String> storePhotoUrl;

    storePhotoUrl 为map结构,在html页面中,通过list进行遍历,通过??判断是否有值,通过?size得到集合的长度

    通过 <#list 0..6 as  t >  

        {t}

       </#list >

    会输出0123456

                                <#if storePhotoUrl??>
                                    <div style="float: left;height:200px;position:relative;text-align:center;margin-left:120px;"> 
                                    <#list storePhotoUrl?keys as st>
                                        <div style="float: left;height:200px;position:relative;text-align:center;margin-right:5px;">
                                            <img  src="${storePhotoUrl.get(st)}" width="100" height="100" id="img${st}">
                                            <br/>
                                            <input type="hidden"     name="picnames"    id="fs_img${st}" value="${storePhotoUrl.get(st)}" />
                                            <input type="hidden"     name="status"    value="2"    id="fs_status${st}" />
                                            <input type="file"         id="goods${st}"  fs="${st}"    status="修改" />
                                            <input type="button" name="clean"     value="清除" fs="${st}" class="del_addgoods"/>
                                        </div>
                                    </#list>
                                    <#if storePhotoUrl?size lt 7>
                                        <#list (storePhotoUrl?size+1)..7 as t>
                                            <div style="float: left;height:200px;position:relative;text-align:center;margin-right:5px;">
                                                <img  src="" name="img${t}"  id="img${t}" width="100" height="100">
                                                <br/>
                                                <input type="hidden"     name="goods_fs"    id="fs_img${t}" fs="${t}"/>
                                                <input type="hidden"     name="status"    value="2"    id="fs_status${t}" />
                                                <input type="file"         id="goods-${t}"  fs="${t}"    status="上传" />
                                                <input type="button" name="clean"     value="清除" fs="${t}" class="del_addgoods"/>
                                            </div>
                                        </#list>
                                    </#if>
                                <#else>
                                        <div style="float:left;margin-left:100px" class="goods_image" id="goods_image">
                                        <input type="file" value="批量上传" id="allFile" status="批量上传"/><br>
                                        <span><font color="red">批量上传只适用于第一次上传且总和能上传七个。</font></span><br/>
                                         <#list 0..6 as t>
                                            <div style="float: left;height:200px;position:relative;100px;text-align:center;margin-right:5px;">
                                                <img src="空" name="img${t}"  id="img${t}"  width="100" height="100"/>
                                                <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                <input type="hidden" name="goods_fs" id="fs_img${t}" fs="${t}"/>
                                                <input type="hidden" name="status" value="2" id="fs_status${t}"/>
                                                <input type="file" id="goods${t}" fs="${t}" status="上传"/>
                                                <input type="button" name="clean" value="清除" fs="${t}" class="del_addgoods"/>
                                            </div>
                                        </#list>
                                </#if>
    $("input[name='clean']").click(function(){
            var fs=$(this).attr("fs");
            console.log("-------fs--------"+fs);
            $("#img"+fs).attr("src","");
            //$("#fs_status"+fs).val("0");
            $("#fs_img"+fs).attr("name","del_pic");
            $("#fs_img"+fs).val("");
        });

    这段js的代码意思是

    先通过jQuery选择器,绑定name=clean的input ,增加一个点击事件,当点击在这个input按钮上时,获取当前点击的属性为fs的值,这个值就是遍历出来的0123456中的一个,通过这个值,再进行字符串的拼接,就可以获取当前input按钮id

  • 相关阅读:
    完毕port(CompletionPort)具体解释
    [Java聊天室server]实战之五 读写循环(服务端)
    ImageMagick的安装及使用
    STL学习小结
    ORACLE中%TYPE和%ROWTYPE的使用
    命令模式在MVC框架中的应用
    代码阅读分析工具Understand 2.0试用
    SimpleDateFormat 的线程安全问题与解决方式
    C++垃圾回收机制
    TH文字编辑器开发的第一个游戏,唐伯虎泡妞
  • 原文地址:https://www.cnblogs.com/jiafuwei/p/6008781.html
Copyright © 2020-2023  润新知