tomcat/conf/web.xml下加:
<mime-mapping> 
<extension>xls</extension> 
<mime-type>application/msexcel</mime-type> 
</mime-mapping>
需要导出的文件头上加:
<%@ page contentType="application/vnd.ms-excel" %>搜索一下excel论坛里有许多贴子的

解决方案 »

  1.   

    把下面的代码存为一个.jsp文件,运行一下就知道了
    <%@ page contentType="application/vnd.ms-excel; charset=GB2312"%>
    <%
    response.setContentType("application/vnd.ms-excel; charset=GB2312");
    %>
    <html><head>
    <meta http-equiv="Content-Language" content="zh-cn">
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="application/vnd.ms-excel; charset=gb2312">
    <title>a</title>
    </head><body><table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
      <tr>
        <td width="16%">222222222</td>
        <td width="16%">bbb</td>
        <td width="17%">bbb</td>
        <td width="17%">bbb</td>
        <td width="17%">bbb</td>
        <td width="17%">bbb</td>
      </tr>             
      <tr>              
        <td width="16%">bbb</td>
        <td width="16%">bbb</td>
        <td width="17%">bbb</td>
        <td width="17%">bbb</td>
        <td width="17%">bbb</td>
        <td width="17%">bbb</td>
      </tr>            
      <tr>             
        <td width="16%">bbb</td>
        <td width="16%">bbb</td>
        <td width="17%">bbb</td>
        <td width="17%">bbb</td>
        <td width="17%">bbb</td>
        <td width="17%">bbb</td>
      </tr>
    </table></body></html>
      

  2.   

    http://jakarta.apache.org/poi/index.htmlSet of APIs for creating, reading, and writing files based upon the OLE 2 Compound Document Format using only Java (no native stuff). Currently, OLE 2 Compound Document Format itself and Microsoft Excel (XLS) file formats are provided.
      

  3.   

    你可以吧excel理解为是一种数据库,操作方式和sqlserver等数据库一样,这样你的问题就解决了