poi读取xlsx格式的程序单独运行正确 用jsp调用出现无法执行new XSSFWorkbook的情况,也无报错
public class Forexecute extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
XSSFWorkbook rwb = null;
MultipartFormDataRequest mrequest = null;
try{
rwb = new XSSFWorkbook(new BufferedInputStream(new FileInputStream(new File("D:\\qzworkspace\\1.xlsx"))));
// 读取第一章表格内容
XSSFSheet sheet = rwb.getSheetAt(0);
// 定义 row、cell
XSSFRow row;
String cell;
// 循环输出表格中的内容
for (int i = sheet.getFirstRowNum()+1; i < sheet.getPhysicalNumberOfRows(); i++) {
row = sheet.getRow(i);
for (int j = row.getFirstCellNum(); j < row.getPhysicalNumberOfCells(); j++) {
// 通过 row.getCell(j).toString() 获取单元格内容,
cell = row.getCell(j).toString();
System.out.print(cell + "\t");
}
System.out.println("");
}
}catch(Exception e) {
System.out.println("已运行xlRead() : " + e );
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
public static void main(String args[]) throws ServletException, IOException
{
Forexecute er = new Forexecute();
HttpServletRequest request = null;
HttpServletResponse response=null;
er.doGet(request, response);
}
}
上面是我java部分的程序,单独执行main函数调用poi读取excel没有问题,但是用jsp调用这个方法就会在执行new XSSFWorkbook()处停止,也无任何报错,求大神们帮帮忙看一下。