我想用JSF将Excel文件上传到JBoss服务器,所以我使用了Tomahawk。
以下是观点:
<%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
<h:form id="MF" enctype="multipart/form-data" >
<x:inputFileUpload id="fileupload" value="#{dataentryctl.minvoice}" storage="file" required="false" />
<h:commandButton id="Submit" type="button" action="#{invoiceentryctl.PersistData}" value="save"
onclick="revalidateF12();submitForm()" onkeydown="keyDownEvents(this)" />
</h:form>
这是控制器/型号:
package panaceaFACweb.FACCtlbean;
import org.apache.myfaces.custom.fileupload.UploadedFile;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class dataentryctl {
private UploadedFile minvoice;
public UploadedFile getMinvoice() {
return minvoice;
}
public void setMinvoice(UploadedFile minvoice) {
this.minvoice = minvoice;
}
public String PersistData() {
load();
return null;
}
public void load() {
ParseXLS parseXls = new ParseXLS();
try {
InputStream input = minvoice.getInputStream();
// ...
} catch (IOException e) {
e.printStackTrace();
}catch (Exception e) {
e.printStackTrace();
}
}
}
我有以下JAR:
与JSF相关的其他JAR已经存在。其他JSP页面工作正常。
我在NullPointerException
行上找到了InputStream input = minvoice.getInputStream();
。