serlet中不能调用POI的包吗?

报错:Source not found for ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 258

源码:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doPost(request,response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub

        try{


            response.setContentType("application/vnd.ms-excel;charset=utf-8");
               response.setHeader("Content-Disposition", "attachment;filename="
                 + new String("测试.xls".getBytes(), "iso-8859-1"));

               ServletOutputStream out = response.getOutputStream();

               BufferedInputStream bis = null;
               BufferedOutputStream bos = null;

               try {

                bis = new BufferedInputStream(this.getInputStream());
                bos = new BufferedOutputStream(out);

                byte[] buff = new byte[2048];
                int bytesRead;

                while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
                 bos.write(buff, 0, bytesRead);
                }

               } catch (final IOException e) {
                System.out.println("IOException.");
                throw e;
               } finally {
                if (bis != null)
                 bis.close();
                if (bos != null)
                 bos.close();
               }





        }catch(Exception e){

            e.printStackTrace();
        }

    }
    private InputStream getInputStream() {

              [color=red]//运行下面那一行就报错[/color]
        [color=red]  HSSFWorkbook wb = new HSSFWorkbook();[/color]
           HSSFSheet sheet = wb.createSheet("sheet1");

           HSSFRow row = sheet.createRow(0);

           HSSFCell cell = row.createCell((short) 0);



           cell.setCellValue("序号");

           cell = row.createCell((short) 1);

           cell.setCellValue("姓");

           cell = row.createCell((short) 2);

           cell.setCellValue("名");

           cell = row.createCell((short) 3);

           cell.setCellValue("年龄");

           //创建一行记录
           row = sheet.createRow(1);

           cell = row.createCell((short) 0);

           cell.setCellValue("1");

           cell = row.createCell((short) 1);
           cell.setCellValue("刘");

           cell = row.createCell((short) 2);

           cell.setCellValue("继忠");

           cell = row.createCell((short) 3);

           cell.setCellValue("25");


           ByteArrayOutputStream os = new ByteArrayOutputStream();

           try {
            wb.write(os);
           } catch (IOException e) {
            e.printStackTrace();
           }

           byte[] content = os.toByteArray();
           InputStream is = new ByteArrayInputStream(content);
           return is;
        }

经过测试,在Servlet中调用HSSFWorkbook wb = new HSSFWorkbook();是不会出错的,请确认一下你的POI的版本和所需要的LIB有没有导入到WEB工程中。

你可以用以下代码测试正确性。该代码在我机器上正常运行。
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename="
+ new String("测试.xls".getBytes(), "iso-8859-1"));
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("test");
OutputStream out = response.getOutputStream();
wb.write(out);
out.flush();
out.close();

是不是有Filter,是Filter出错了吧?