jsp使用smartupload下载文件完成后怎么对原页面进行提示更新
通过表单提交所需下载数据的部门和数据时间段,传递给后台servlet执行数据导出下载,同时主界面弹出数据正在下载提示,文件下载完成后,主界面刷新或者隐藏提示小窗口,不知道这个效果怎么实现,效果图如下主界面
选择部门时间后点击导出,弹出提示框,按钮不可用
数据处理完成弹出文件保存窗口
文件下载完成,点击关闭
主要问题是主界面状态我怎么变回原来的状态,即没有提示框,按钮可点击
下面上代码
主界面index.jsp部分代码
表单
<form action="DownloadServlet" method="post">
<table class="imagetable">
<tr>
<td>请选择部门:</td>
<td>
<select name="selectbm" style="height:24px;width:101px" id="selectbm">
<option value="gs">工商局</option>
<option value="mz">民政局</option>
<option value="bz">编制部门</option>
<option value="guos">国税局</option>
<option value="ds">地税局</option>
</select>
</td>
</tr>
<tr>
<td>开始时间:</td>
<td>
<input name="startTime" id="startTime" type="text" class="Wdate" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'endTime\')}'})" />
</td>
</tr>
<tr>
<td>结束时间:</td>
<td>
<input name="endTime" id="endTime" type="text" class="Wdate" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startTime\')}'})" />
</td>
</tr>
<tr>
<td colspan="3">
<input id="btnSubmit" value="导出excel" type="submit" onClick="dataexport()" />
</td>
</tr>
</table>
</form>
点击事件
function dataexport()
{
sending.style.visibility="visible";
document.getElementById("btnSubmit").disabled="disable";
}
Servlet部分代码
String orcl="";
CallableStatement stmt = null;
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(Exception e)
{
}
try
{
PageContext pageContext =
JspFactory.getDefaultFactory().getPageContext(this,request,response,null,true,8192,true); //这里就是取得jsp页面的PageContext对象的方法。
WritableWorkbook book1=Workbook.createWorkbook(new File("d:/Test.xls"));
WritableSheet sheet1 = book1.createSheet("第一页", 0);
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","123");
//Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@32.121.1.33:1521:corpdb","tzpt","tzpt2014");
orcl+="<TABLE BORDER='1' width='55%' cellpadding='3' align=center>";
orcl+="<TR><TD>"+"<b>reg_no</b>"+"</TD>";
orcl+="<TD>"+"<b>corp_name</b>"+"</TD>";
orcl+="<TD>"+"<b>addr</b>"+"</TD>";
orcl+="<TD>"+"<b>areacode</b>"+"</TD>";
orcl+="<TD>"+"<b>oper_man_name</b>"+"</TD></TR>";
int i=1;
stmt = conn.prepareCall("call data_export(?,?,?)");
stmt.setString(1, request.getParameter("selectbm"));
stmt.setString(2, request.getParameter("startTime"));
stmt.setString(3, request.getParameter("endTime"));
int rownum=stmt.executeUpdate();
PreparedStatement pstmt=conn.prepareStatement("select * from tjj_gsdata_export_temp");
ResultSet rs=pstmt.executeQuery();
//插入符合条件的数据至
//String getcondatastr="insert into tjj_gsdata_export_temp select * from gs_corpmain_s where updatetime between to_date('"
//+request.getParameter("startTime")+"','yyyy/mm/dd') and to_date('"+request.getParameter("endTime")+"','yyyy/mm/dd')";
//Statement stat = conn.createStatement();
//stat.executeUpdate(getcondatastr);
//stat.close();
sheet1.addCell(new Label(0,0,"单位序号"));
sheet1.addCell(new Label(1,0,"社会信用代码"));
sheet1.addCell(new Label(2,0,"新登记注册号"));
sheet1.addCell(new Label(3,0,"原登记注册号"));
sheet1.addCell(new Label(4,0,"组织机构代码"));
sheet1.addCell(new Label(5,0,"单位名称"));
sheet1.addCell(new Label(6,0,"法定代表人"));
sheet1.addCell(new Label(7,0,"单位详细地址"));
sheet1.addCell(new Label(8,0,"行政区划代码"));
sheet1.addCell(new Label(9,0,"邮政编码"));
sheet1.addCell(new Label(10,0,"联系电话"));
sheet1.addCell(new Label(11,0,"行业代码"));
sheet1.addCell(new Label(12,0,"单位类别"));
sheet1.addCell(new Label(13,0,"注册资本"));
sheet1.addCell(new Label(14,0,"变动类型"));
sheet1.addCell(new Label(15,0,"变动时间"));
sheet1.addCell(new Label(16,0,"备注"));
while(rs.next())
{
sheet1.addCell(new Label(0,i,rs.getString("guid")));
sheet1.addCell(new Label(2,i,rs.getString("reg_no")));
sheet1.addCell(new Label(5,i,rs.getString("corp_name")));
sheet1.addCell(new Label(7,i,rs.getString("addr")));
sheet1.addCell(new Label(8,i,rs.getString("areacode")));
sheet1.addCell(new Label(6,i,rs.getString("oper_man_name")));
sheet1.addCell(new Label(13,i,rs.getString("Reg_CAPI")));
sheet1.addCell(new Label(11,i,rs.getString("ADMIT_Main")));
//将行列的值写入页面
i++;
}
rs.close();
pstmt.close();
conn.close();
//开始执行写入操作
book1.write();
//关闭流
book1.close();
response.reset();//如果在weblogic底下同样要加上此句
//新建一个SmartUpload对象
SmartUpload su=new SmartUpload();
//初始化
su.initialize(pageContext);
//设定contentDisposition为null以禁止浏览器自动打开文件,
//保证点击连接后是下载文件。若不设定,则下载的文件扩展名为doc时,
//浏览器将自动用word打开。扩展名为pdf时,浏览器将用acrobat打开.
su.setContentDisposition(null);
//下载文件
su.downloadFile("D:\\Test.xls");
//response.sendRedirect("index.jsp");
pageContext.getResponse().getOutputStream().close();
//out.clear();
//out=pageContext.pushBody();
//response.sendRedirect("index.jsp");
}
catch(Exception e)
{
e.printStackTrace();
}
现在主要问题就是文件下载完成后我的index.jsp怎么状态还原,本人javaweb开发新手,勿喷,还请帮忙
[此贴子已经被作者于2016-7-26 09:26编辑过]