Primefaces 中upload 怎么不显示呢
java
package com.mytest;
import org.primefaces.model.UploadedFile;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
/**
* Created with IntelliJ IDEA.
* User: Administrator
* Date: 13-4-17
* Time: 下午3:57
* To change this template use File | Settings | File Templates.
*/
@ManagedBean
@RequestScoped
public class FileUploadBean {
private UploadedFile file;
public UploadedFile getFile() {
return file;
}
public void setFile(UploadedFile file) {
this.file = file;
}
public void upload() {
FacesMessage msg = new FacesMessage("Successful", file.getFileName() + " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null, msg);
}
}
xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
template="../templates/ui.xhtml">
<ui:define name="content">
<div class="entry">
<h3 >This upload </h3>
<h:form enctype="multipart/form-data">
<p:messages showDetail="true"/>
<p:fileUpload value="#{fileUploadBean.file}" mode="simple"/>
<br/><br/>
<p:commandButton value="Submit" ajax="false" actionListener="#{fileUploadBean.upload}"/>
</h:form>
</div>
</ui:define>
</ui:composition>
xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"