1.制造一个隐藏的iframe
<iframe name='hidden_frame' id="hidden_frame" style='display:none'></iframe>
?
2.设置上传表单target
<form id="myform" name="uploadform" method="post" enctype="multipart/form-data" target="hidden_frame">
?
3.上传文件servlet设置回调函数
?PrintWriter?? writer?? =?? response.getWriter();?
? writer.println("<script>parent.showResponse('NG')</script>");
?writer.close();
?
4.jsp页面回调函数中判断上传结果
if(str=="OK")
?{
??showMessage("上传文件成功!");
?? query();
??return;
?}
?else
?{
??showMessage("上传文件失败!");?
??return;
?}
5.finish