FormFile image = infoForm.getImage();//取得上传的文件 
String size = (image.getFileSize() + " bytes");//文件大小 
String fileName= image.getFileName();//文件名 
String contentType = image.getContentType(); 
String aa="";
try { 
InputStream stream = image.getInputStream();//把文件读入 
String filePath =request.getRealPath("/upload");//取当前系统路径 
ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
OutputStream bos = new FileOutputStream(filePath + "/" + 
image.getFileName()); 
//建立一个上传文件的输出流,将上传文件存入web应用的根目录。 
aa = filePath+"/"+image.getFileName();
 infoVO.setImageFile(aa);
int bytesRead = 0; 
byte[] buffer = new byte[8192]; 
while ( (bytesRead = stream.read(buffer, 0, 8192)) != -1) { 
bos.write(buffer, 0, bytesRead);//将文件写入服务器 

bos.close(); 
stream.close();
}catch(Exception e){ 
System.err.print(e); 

//========================infoVO = infoDAO.add(infoVO);上面是我的一个上传的代码,文件名字路径什么的都能取到,就是我要把保存后的文件路径赋值给infoVO.setImageFile(aa);,aa在调试时候的显示路径是d:\\update/aa.jpg这样的格式,不知道有没错误,如果我不用infoVO.setImageFile(aa);这个也就是不把值赋到infoVO的时候能够把基本信息写入数据库并且照片文件也能上传到对应的文件夹下,但是我如果用了这个赋值方法则会报错,我不知道这个有没直接原因,其中ImageFile定义的是string型的。路过朋友帮忙看一下。