最近用到一个小功能,即双击相册列表中的照片时,把此照片设为头像,由于我用的是iframe,所以在action处理过后返回的jsp页面不能达到父页面的刷新。
IPictureMgr pictureMgr = (IPictureMgr) getBean("pictureMgr");
List result = pictureMgr.get(username);
req.setAttribute("result", result);
req.setAttribute("filepath", filepath);
return mapping.findForward("add");
如果这样的话每次只能手动刷新整个页面才能实时显示修改的头像,如果想刷新父页面,只需要在script中做如下处理:
function aaaa(i,filename){
alert(i);
var filepath = document.getElementById("picture"+i).value;
alert(filepath);
window.location.href ='pictures.do?method=sethead&filepath='+filepath+'&filename='+filename;
parent.location.reload();//刷新父页面
}
这是双击事件function