0
我想使用RichFaces上傳文件,但它不上傳文件。 我所做的是:
file.jsp傳輸錯誤發生
<h:form>
<rich:panel header="FileUpload demostration">
<rich:fileUpload
fileUploadListener="#{fileUploadBean.listener}"
id="upload"
maxFilesQuantity="10"
immediateUpload="true"
/>
</rich:panel>
</h:form>
file.java
public class FileUploadBean {
private List<String> uploadedList;
private UploadItem item;
public FileUploadBean(){
this.uploadedList = new LinkedList<String>();
}
public void listener(UploadEvent event) throws IOException {
this.setItem(event.getUploadItem());
getUploadedList().add(this.getItem().getFileName());
System.out.println("Elements in the list: ");
for(String name : this.getUploadedList()){
System.out.println(name);
}
}
/**
* @return the uploadedList
*/
public List<String> getUploadedList() {
return uploadedList;
}
/**
* @param uploadedList the uploadedList to set
*/
public void setUploadedList(List<String> uploadedList) {
this.uploadedList = uploadedList;
}
/**
* @return the item
*/
public UploadItem getItem() {
return item;
}
/**
* @param item the item to set
*/
public void setItem(UploadItem item) {
this.item = item;
}
} 和我在web.xml這個補充說:
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>enable</param-value>
</context-param>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
當我運行它,它給了我jsp頁面,我可以選擇圖像,但是當我做它加載它說transfer error occured
併發生在這一行: '#{fileUploadBean.listener}' java.lang.NullPointerException
我在哪裏出錯? 謝謝!