关于文件上传
public static void upload(String strPath, ServletConfig config,HttpServletRequest request, HttpServletResponse response) {File dir = new File(strPath);String w = JdjWsxydUpload.getFilesRecursive(dir);if (w.equals("ligang")) {} else {strPath += "/" + w;File fileDir = new File(strPath);if (fileDir.exists()) {System.out.println("删除文件信息成功!!!");fileDir.delete();}}SmartUpload su = new SmartUpload();try {su.initialize(config, request, response);su.upload();for (int i = 0; i < su.getFiles().getCount(); i++) {com.jspsmart.upload.File file = su.getFiles().getFile(i);// 若文件不存在则继续if (file.isMissing())continue;// 将文件另存file.saveAs("/webgroup/jdj/wsxyd/"+ JdjWsxydUpload.getOneName() + "."+ file.getFileExt());}} catch (SmartUploadException e) {e.printStackTrace();} catch (Exception e) {e.printStackTrace();}}private static String getOneName() {String name = "";name = "wsxyd" + System.currentTimeMillis();return name;}public static String getFilesRecursive(File dir) {if (dir.isDirectory()) {String sub[] = dir.list();if (sub.length > 0) {return sub[0];} else {return "ligang";}} else {return "ligang";}}public static void main(String[] args){File dir = new File("C:/windows/Help");String w = JdjWsxydUpload.getFilesRecursive(dir);System.out.println(w);}