关于poi导出Excel的问题。
现在在做Excel的导出功能,我看了网上的论坛,都是用poi和jxl做的,综合比较了一下选择了poi,但是在导出demo这一块,我直接访问页面可以弹出下载框,如果结果struts2的返回跳转到该页面,则没有任何反应,有些小晕,请高手指点错误出在哪里。现在贴出代码:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="application/vnd.ms-excel" language="java"
import="java.util.*,com.Export"%>
<%
response.setHeader("Content-Disposition","attachment;filename=exportdata.xls");
response.setContentType("application/vnd.ms-excel");
Export ex = new Export();
ex.buildStudentExcel("exportdata.xls",response.getOutputStream());
%>
<%
out.clear();
out=pageContext.pushBody();
%>
<action name="expExcel" class="measureAction" method="expExcel" >
<result name="success" >/auditcheck/measure/123.jsp</result>
</action>