我使用Primefaces4.0和JSF2.0,我知道Primefaces的一些基礎知識。 對我來說p:fileUpload
不工作,它以前工作。不知道發生了什麼 當我從文件選擇器中選擇任何文件時,沒有文件在p:fileUpload文件中填充。Primefaces p:fileUpload不起作用
這裏是我的代碼:
<p:panel style="font-size:15px;" header="Upload">
<p:fileUpload fileUploadListener="#{addAgentxls.handleFileUpload}" mode="advanced" dragDropSupport="true"
update="messages status" sizeLimit="100000" style="font-size:12px;" />
<p:growl id="messages" showDetail="true"/>
<p:outputLabel id="status" style="font-size:13px;" value="#{addAgentxls.status }"/>
</p:panel>
類文件:
@ManagedBean(name = "addAgentxls", eager = true)
@SessionScoped
public class AddAgentUsingXLS {
public AddAgentUsingXLS(){
}
public void handleFileUpload(FileUploadEvent event) {
FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null, msg);
}
}
的web.xml:
<!-- File Uploading Constraints -->
<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>
我也看到This爲我做什麼 有錯誤在谷歌Chrome瀏覽器上
Uncaught TypeError: Object [object Object] has no method 'fileupload'
fileupload.js.xhtml?ln=primefaces&v=4.0:1
它值得嗎?
我不確定您是否已將enctype =「multipart/form-data」添加到您的表單中。 – psi
是面板添加在h:表格 – Sarz
請參閱http://stackoverflow.com/questions/16166039/uncaught-typeerror-cannot-read-property-value-of-undefined-using-primefaces-f/16168985#16168985 – psi