struts1.2+tomcat5.0
excel导入sql2000数据库
在本地项目上导入几M的excel都不会报错,但是放在服务器上超过70k的就报错 报错信息是
Processing of multipart/form-data request failed. Socket read faileAction里面的代码如下
/******************上传文件*****************************/
String encoding = request.getCharacterEncoding();
if ((encoding != null) && (encoding.equalsIgnoreCase("utf-8"))){
//如果没有指定编码,编码格式为gb2312
response.setContentType("text/html; charset=gb2312");
}
//把文件读入
InputStream stream = file.getInputStream();
OutputStream bos = new FileOutputStream(filePath+"save_xb_importexcel\\" +file.getFileName()); request.setAttribute("fileName",filePath+"save_xb_importexcel\\"+file.getFileName());
int bytesRead = 0;
byte[] buffer = new byte[81920];
while ((bytesRead = stream.read(buffer, 0, 81920)) != -1)
{
//将文件写入服务器
bos.write(buffer, 0, bytesRead);
}
bos.close();
stream.close();
/******************上传文件 end*****************************/
jsp页面的代码如下:<html:form action="/xb/hkxbImportExcel.do" method="post" styleId="web_xb_form" enctype="multipart/form-data" >
<html:file styleId="files" property="theFile" style="height:25px;" />
excel导入sql2000数据库
在本地项目上导入几M的excel都不会报错,但是放在服务器上超过70k的就报错 报错信息是
Processing of multipart/form-data request failed. Socket read faileAction里面的代码如下
/******************上传文件*****************************/
String encoding = request.getCharacterEncoding();
if ((encoding != null) && (encoding.equalsIgnoreCase("utf-8"))){
//如果没有指定编码,编码格式为gb2312
response.setContentType("text/html; charset=gb2312");
}
//把文件读入
InputStream stream = file.getInputStream();
OutputStream bos = new FileOutputStream(filePath+"save_xb_importexcel\\" +file.getFileName()); request.setAttribute("fileName",filePath+"save_xb_importexcel\\"+file.getFileName());
int bytesRead = 0;
byte[] buffer = new byte[81920];
while ((bytesRead = stream.read(buffer, 0, 81920)) != -1)
{
//将文件写入服务器
bos.write(buffer, 0, bytesRead);
}
bos.close();
stream.close();
/******************上传文件 end*****************************/
jsp页面的代码如下:<html:form action="/xb/hkxbImportExcel.do" method="post" styleId="web_xb_form" enctype="multipart/form-data" >
<html:file styleId="files" property="theFile" style="height:25px;" />
数值改大点
bos.write(buffer, 0, bytesRead);
bos.flush();flush一下呢?
肯定不是这个原因。塞不进db,你把db的那个字段调大一点。PS:db的这个字段是什么类型?image?binary?
db字段用的是varchar的 不是字段出问题
只要excel小于70K的导入就没问题,我导入的是要excel的数据,不是要文件的。所以我一直都搞不清楚是咋回事啊