2013-02-28 5 views
0

Spring 3.0.6.RELEASE 및 Primefaces 2.2.1을 사용하여 웹 응용 프로그램을 만들고 있습니다. 응용 프로그램에 FileUpload 구성 요소가 있습니다. 파일 업로드가 작동하지 않습니다. 그리고 업로드 backingbean FileUploadController의() 함수는 호출되지 않습니다.Primefaces FileUpload가 Spring과 함께 작동하지 않습니다.

public class FileUploadController { 

    private String destination="D:\\"; 

    public void upload(FileUploadEvent event) { 
     System.out.println("uplaod"); 
     FacesMessage msg = new FacesMessage("Success! ", event.getFile().getFileName() + " is uploaded."); 
     FacesContext.getCurrentInstance().addMessage(null, msg); 

     try { 
      copyFile(event.getFile().getFileName(), event.getFile().getInputstream()); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 

    } 
    public void copyFile(String fileName, InputStream in) { 
      try { 

       OutputStream out = new FileOutputStream(new File(destination + fileName)); 

       int read = 0; 
       byte[] bytes = new byte[1024]; 

       while ((read = in.read(bytes)) != -1) { 
        out.write(bytes, 0, read); 
       } 

       in.close(); 
       out.flush(); 
       out.close(); 

       System.out.println("New file created!"); 
       } catch (IOException e) { 
       System.out.println(e.getMessage()); 
       } 
    } 
} 

이란 무엇입니까 :

<p:dialog widgetVar="assetUploadDialog" modal="true" minHeight="300" 
        minWidth="550" closable="true" draggable="true" 
        closeOnEscape="true" header="Asset upload"> 
      <h:form id="formuploader" > 
       <p:fileUpload id="fileuploader" 
         fileUploadListener="#{fileUploadController.upload}" 
         sizeLimit="100000" 
         allowTypes="*.jpg;*.gif;*.png;*.pdf;*.png;*.doc?x;*.xls;*.xlsx;"/> 
      </h:form> 
     </p:dialog> 

그리고 내 FileUploadController 빔 클래스의

내 index.xhtml에서

<filter> 
    <filter-name>PrimeFaces FileUpload Filter</filter-name> 
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class> 
</filter> 
<filter-mapping> 
    <filter-name>PrimeFaces FileUpload Filter</filter-name> 
    <servlet-name>Faces Servlet</servlet-name> 
</filter-mapping> 

:

나는이 내 web.xml 파일에 하나를 포함 내 문제에 대한 해결책?

+0

내 빈 클래스에서 같은 양식 태그에 enctype="multipart/form-data"를 추가? – queans

+0

Primefaces v3.5가 2 월 4 일에 http://blog.primefaces.org/?p=2436에 출시되었습니다. –

+0

감사합니다.하지만 Primeface 2.2.1을 사용하여 작업을 완료해야합니다. – queans

답변

0

시도하는 이유는 invoked.What하지 않습니다이 example

+0

시도했습니다.하지만 작동하지 않습니다. . – queans

관련 문제