2013-02-05 1 views
0

업로드 된 파일을 처리 할 서블릿이 있습니다. 아파치 공용 파일 업로드 라이브러리가이를 위해 사용됩니다.아파치 커먼즈 파일 업로드 파일이 손상됨

문제는 파일이 손상되었다는 것입니다. 기호 "~"가 "?"에 대체 된 것처럼 보입니다. 파일에.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
     "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
    <title></title> 
</head> 
<body> 

<FORM action="http://localhost:8081/wihome-connector-bpm/bpmFileUpload" 
     enctype="multipart/form-data" 
     method="post"> 

     What files are you sending? 
     <INPUT type="file" name="uploadedFiles"><BR> 

     <INPUT type="submit" value="Send"> 

     <INPUT type="reset"> 

</FORM> 


</body> 
</html> 

그리고 그 서블릿입니다 :

여기 내 HTML 양식입니다

public class FileUploadServlet extends HttpServlet { 

    private static final Log LOG = LogFactory.getLog(FileUploadServlet.class); 

    /** 
    * {@inheritDoc} 
    */ 
    @Override 
    protected void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { 


     try { 
      boolean isMultipart = ServletFileUpload.isMultipartContent(request); 
      if (isMultipart) { 
       FileItemFactory factory = new DiskFileItemFactory(); 
       ServletFileUpload upload = new ServletFileUpload(factory); 

       List items = upload.parseRequest(request); 

       Iterator iter = items.iterator(); 
       while (iter.hasNext()) { 
        FileItem item = (FileItem) iter.next(); 
        if (!item.isFormField()) { 
         LOG.info("Uploading file: " + item.getName()); 
         byte[] fileContents = IOUtils.toByteArray(item.getInputStream()); 
         //... 
        } 
       } 
      } 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
    } 


} 

나는 이미지를 enter image description here

을 업로드하려고하지만 그 대신 내가 얻을 :

enter image description here

도와주세요. 무엇이 문제 일 수 있습니까?

답변

0

좋아, 필터에 문제가 발생했습니다. 프로젝트에는 풍부한 서블릿보다 먼저 요청이 중단 된 필터가 있습니다.