private String uploadPath = "D://java//svn//gwaps1.3//WebRoot//images//"; public ActionForward fileUpload(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ProductForm pf = (ProductForm) form; FormFile myFile = pf.getMyfile(); String myFileName = null; if(myFile != null) { System.out.println("fileName = "+myFile.getFileName()); myFileName = myFile.getFileName(); FileOutputStream fos = new FileOutputStream(uploadPath +myFileName); fos.write(myFile.getFileData()); fos.flush(); fos.close(); } String dataPath = (uploadPath+myFileName).substring(29).replaceAll("////", "/"); System.out.println("数据库路径:"+dataPath); request.setAttribute("images", dataPath); System.out.println(request.getAttribute("images")); return mapping.findForward("fileUploadsuccess"); }