目前正在进行的项目中,后台需要实现一次性上传多张图片的功能,现记录实现的过程如下。
1.设置功能方法的点击事件
var imga = ''+imgTitle; //携带该记录的主键id过去
2.点击方法的具体实现
html DOM对象
function imgrow(id) {
var imgTitle= '图片';if(!top.checkHiddenSet("plateNumFlag")){
imgTitle= '车辆图片管理';
}
var detailLog= $('#myImg').dialog(
{
title: imgTitle,//这里动态设置标题显示
width:945,
height:'90%',
modal:true,
closable:true,
href:"goods/indexImg?id="+id,//跳转到图片展示的dialog对话框中
onLoad: function () {
img(id);//图片的回显方法
},
buttons : [ {
text :"关闭",
handler : function() {
$('#t_goods').datagrid('reload');
$('#t_goods').datagrid('unselectAll');
detailLog.dialog('close');
}
} ],
onClose:function(){//关闭右上方红叉的方法
fileNums= [];//清空图片id数组
$('#t_goods').datagrid('reload');
$('#t_goods').datagrid('unselectAll');
}
});//$("#id").val(id);
};
3.回显方法img()的实现
function img(id){//id是标的id
$.ajax({
type:"get",
async:false,
dataType :'json',
url: parent.baseUrl+"goods/findGoodsimg/" +id, //获取关于该记录的所有的图片的信息
success: function (result) {
var json=eval(result);//循环遍历获取到的图片信息的情况
showGoodsImgs(id,json);//显示记录关联的图片信息情况
createImgContainer(id,json);//创建一次向上传多张图片的容器
}
});
}
控制器中获取记录的图片信息的具体方法
/*** 查询单个标的的图片*/@RequestMapping(value= "/findGoodsimg/{id}", method =RequestMethod.GET)
@ResponseBo