后台获取图片信息,在页面展示

做的一个项目,有一个展示信息的页面,同时要展示相应的图片。

一开始是想用jQuery easyUI的datagrid,但是这个显示效果不好,会出现表格的一些特性,展示图片时会有加减号控制。其实是我想多了,图片就放在本地,数据库表中只是存储的图片的基本信息(ID,URL等),其实可以在后台获取这些信息后直接传到页面,在相应的地方展示出来就可以了。在这我是在一个form表单中展示。

后台controller

@ResponseBody
    @RequestMapping("/apply/veriApplyGet")
    public String getVeriApply(String id, String techCls){
        String sql = "";
        if("1".equals(techCls)){
            sql = "select p.id, p.data_id, p.pics_url, p.pics_name from TBL_BASE_PICS p,TBL_TECH_ACHV a where p.data_id = a.id and a.id = '"+id+"' and p.data_cls = '1' ";
        }
        if("2".equals(techCls)){
            sql = "select p.id, p.data_id, p.pics_url, p.pics_name from TBL_BASE_PICS p,TBL_TECH_DEMAND d where p.data_id = d.id and d.id = '"+id+"' and p.data_cls = '2' ";
        }
        List photoList = commonService.execSql4List(sql, true, true);
        Map<String, Object> infoMap = this.getVeriEntityInfo("get", Integer.parseInt(techCls), id);
        infoMap.put("photo", photoList);
        return this.writeJson(infoMap);
    }

前台展示

.ftl

    <div data-options="region:'east',width:360" style="padding:10px 5px;">

          <form id="photoForm1" method="post"></form>

     </div>


script

//处理图片表photoForm
                        var photoForm = "<div style=\"padding:10px;font-size:14px;\">";
                        var photo = data.photo;
                        for(var i = 0; i < photo.length; i++){
                            photoForm += "<img src=\"${ctx}" + photo[i].picsUrl + "\" style=\"height:300px; width:300px;\">";
                        }
                        photoForm += "</div>";
                        $("#photoForm1").html(photoForm);


  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值