@RequestMapping("/upload") public void upload(HttpServletRequest request, HttpServletResponse response) {	Info info = (Info) request.getSession().getAttribute("info");	DiskFileItemFactory factory = new DiskFileItemFactory();	ServletFileUpload upload = new ServletFileUpload(factory);	StringBuffer saveFileName = new StringBuffer();	StringBuffer sbf = new StringBuffer();	Listlist;	try {	list = upload.parseRequest(request);	for (FileItem item : list) {	if (!item.isFormField()) {	String name = item.getName();	saveFileName.append(name);	byte[] bin = item.get();	if (bin.length > 300 * 1024) {	request.setAttribute("errMsg", "上传文件不可大于300K字节");	request.getRequestDispatcher("/testUpLoad/upload.jsp")	.forward(request, response);	return;	}	if (!("".equals(name) || bin.length == 0)) {	super.logDao.save(info, "上传文件", "上传文件:{" + name	+ "} 文件大小:{" + bin.length + "}");	String zpid = super.testDao.upload(bin);	sbf.append(zpid);	sbf.append(",");	}	}	}	String pk = "";	if (sbf.length() > 1 && sbf.lastIndexOf(",") == sbf.length() - 1) {	pk = sbf.substring(0, sbf.length() - 1);	} else {	pk = sbf.toString();	}	if ("".equals(pk) || null == pk) {	request.setAttribute("errMsg", "请选择文件");	request.getRequestDispatcher("/testUpLoad/upload.jsp").forward(	request, response);	} else {	request.setAttribute("imgID", pk);	request.getRequestDispatcher("/testUpLoad/uploadSuccess.jsp")	.forward(request, response);	}	} catch (Exception e) {	super.logDao.save(info, "失败!", "上传文件失败!");	e.printStackTrace();	} }
预览中间表图片的java代码参考:
@RequestMapping("/show") public void show(HttpServletRequest request, HttpServletResponse response) {	String imgId = R.get("imgId");// 图片ID	BLOB blob = super.testDao.findZp(imgId);	if (blob != null) {	// 得到java.sql.Blob对象后强制转换为oracle.sql.BLOB	response.setContentType("image/jpeg");	response.setHeader("Pragma", "No-cache");	response.setHeader("Cache-Control", "no-cache");	response.setDateHeader("Expires", 0);	ServletOutputStream out;	try {	out = response.getOutputStream();	out.write(blob.getBytes(1, (int) blob.length()));	out.flush();	out.close();	} catch (Exception e) {	super.logDao.save(info, "失败!", "读取文件失败!");	e.printStackTrace();	}	} }
其它代码参考附件!