我使用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