【发布时间】:2014-05-04 09:37:28
【问题描述】:
我将 Primefaces4.0 与 JSF2.0 一起使用,我了解 Primefaces 的一些基础知识。
对我来说p:fileUpload 不工作,它以前工作过。不知道发生了什么
当我从文件选择器中选择任何文件时,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 没有为我做任何事情 谷歌浏览器出现错误
Uncaught TypeError: Object [object Object] has no method 'fileupload'
fileupload.js.xhtml?ln=primefaces&v=4.0:1
有什么价值吗?
【问题讨论】:
-
我不确定您是否已将 enctype="multipart/form-data" 添加到您的表单中。
-
是的,面板是在 h:form 中添加的
-
感谢 @psi 链接帮助 BalusC 值得,我使用的是更新版本的 jQuery.js
标签: file-upload jsf-2 primefaces