excel上传至服务器问题
package com.spring.action;
import java.io.FileInputStream;
import java.io.File;
import
java.io.FileNotFoundException;
import
java.io.IOException;
import java.io.InputStream;
import
java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.struts2.ServletActionContext;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import cn.ehoo.baopay.util.UploadFile;
import com.HibernateSessionFactory.wx.HibernateSessionFactory;
import com.lei.wx.MyConn;
import com.opensymphony.xwork2.ActionSupport;
public class LoadAction extends ActionSupport {
private static Session session2;
private POIFSFileSystem fs;
private HSSFWorkbook wb;
private HSSFSheet sheet;
private HSSFRow row;
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session = request.getSession();
private File[] myFile;
private String[] myFileContentType;
private String[] myFileFileName;
static {
Configuration fig = new Configuration().configure("hibernate.cfg.xml");
session2 = HibernateSessionFactory.getSession();
}
public String[] readExcelTitle(InputStream is) {
try {
fs = new POIFSFileSystem(is);
wb = new HSSFWorkbook(fs);
} catch (
IOException e) {
e.printStackTrace();
}
sheet = wb.getSheetAt(0);
row = sheet.getRow(0);
// 标题总列数
int colNum = row.getPhysicalNumberOfCells();
String[] title = new String[colNum];
for (int i = 0; i < colNum; i++) {
title[i] = getStringCellValue(row.getCell((short) i));
}
return title;
}
public Map<Integer, String> readExcelContent(InputStream is) {
Map<Integer, String> content = new HashMap<Integer, String>();
String str = "";
try {
fs = new POIFSFileSystem(is);
wb = new HSSFWorkbook(fs);
} catch (IOException e) {
e.printStackTrace();
}
sheet = wb.getSheetAt(0);
// 得到总行数
int rowNum = sheet.getLastRowNum();
row = sheet.getRow(0);
int colNum = row.getPhysicalNumberOfCells();
// 正文内容应