java 导出为Excel并下载到客户端

1.项目框架:
ssh2+oracle

2.jsp页面

<input id="exportBtn" class="btn" type="button" value="导出为Excel" />
<script type="text/javascript">// 需要导入jquery库
            $(function(){
                $("#exportBtn").click(function(){
                    window.open('<%=basePath%>manager/person/exportPersonList.jcms?departId=${depart.id}','下载','');
                });
            });
</script>

3.struts2配置文件

  <action name="exportPersonList" method="exportPersonList" class="完整类名">
    <result name="success" type="stream">
      <param name="contentType">application/vnd.ms-excel</param>
      <param name="inputName">excelStream</param>
      <param name="contentDisposition">filename="personList.xls"</param>
      <param name="bufferSize">1024</param>
    </result>
  </action>

 未完...

posted @ 2012-08-09 11:57  周雷  阅读(783)  评论(0编辑  收藏  举报
友情链接