干嘛要用struts标签呢,我觉得好麻烦,现在公司也没人用

解决方案 »

  1.   

    public static void saveFile(String filename, FormFile file, String path)
    throws FileNotFoundException, IOException {
    if (file.getFileSize() > 0) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream(); InputStream stream = file.getInputStream();
    createDir(path);
    OutputStream bos =
    new FileOutputStream(path + File.separator + filename);
    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();
    }
    }
      

  2.   

    更正一下,formfile是个接口,直接取好想取不到,可以用javascript
      

  3.   

    通过javascript取,放到隐藏域中,提交后就可以得到了,哈哈