• 添加删除图片


    调用我们自己的添加图片的代码,但是在删除图片时出现问题。hibernate他是可以把所有的图片放在一个set里面他自己更新图片信息

    下面是页面遍历图片,需要用到图片的id:

    <div class="product_detail" style="90%;margin:0px auto;padding-top:10px;text-align:left;">
                    <ul>
                        <s:iterator value="aProofs" var="file" status="stFile">
                            
                            <li style="position:relative;50px;height:50px;">
                                <input type="hidden" name="oldFileId" value="${file.id }"/>
                                <a rel="example_group"  href="/<s:property value="#file.photoPath"/>">
                                    <img src="/<s:property value="#file.photoPath"/>" border="0" style="50px;height:50px; vertical-align:middle;"/>
                                </a>
                                <s:if test='afterSaleService.orderStateSequence==88'>
                                    <a class="o2odelete"></a>
                                </s:if>
                            </li>
                        </s:iterator>
                        
                    </ul>
                </div>

    这个就是页面效果的删除,但并没有删除数据库中的数据:

    $(".o2odelete").click(function(){
            $(this).parent("li").remove();
        })

    上传图片的input:

          <div class="imgs" style="display:block;">
                        <div id="preview1"></div>
                        <input type="file"  name="imageFile" onchange="preview(this,1)"  class="comment-pic-upd" style="border:none;"/>
                        <img src="/m/images/account/file.jpg"/>
                    </div>

    后台需要用到的参数

    private File[] imageFile = null;                                       /*多文件上传*/

    private String[] oldFileId = null;
    private Set<AfterSaleProof> aProofs=null;

          After  after = userAfterSaleFace.getAfter(orderno).get(0);
                    after.setCustomMoney(afterSaleService.getCustomMoney());
                    after.setReason(afterSaleService.getReason());
                    Set<AfterProof> newProof=new HashSet<AfterProof>();
                    if(oldFileId!=null&&oldFileId.length>0){
                        for(String oldId : oldFileId) {
                            AfterProof  oldProof = userAfterSaleFace.getAfterSaleProof(oldId);
                            newProof.add(oldProof);
                        }
                    }
                    if(imageFile!=null){
                        for (int i = 0; i < imageFile.length; i++) {
                            AfterProofaf = new AfterProof();
                            if(imageFile != null){
                                String path=this.saveAttach(imageFile[i], imageFileFileName[i], 1, "afterSaleService");
                                af.setPhotoPath(path);
                                af.setName(imageFileFileName[i]);
                                af.setSerialNum(i+1);
                            }
                            newProofs.add(af);
                        }
                    }
                    after.setAfterProofs(newProofs);        
                    userAfterSaleFace.addOrUpdateAfterSaleService(afterSaleServices, methodArg);

    最后更新一下实体。

  • 相关阅读:
    蔚来汽车笔试题---软件测试
    python 装饰器
    adb
    新手安装禅道至本地
    各种验证码应该如何给值
    int col = Integer.parseInt(args[0]);的用法
    找不到jsp文件:ctrl+shift+R
    通过服务器获取验证码
    Sublime Text 2: [Decode error
    爬虫爬取新闻(二)
  • 原文地址:https://www.cnblogs.com/xiaoxiaojuan/p/6491786.html
Copyright © 2020-2023  润新知