我正在使用<t:inputFileUpload>
from MyFaces从目录中选择一个文件,但是,从ManagedBean,当我尝试获取所选文件的完整路径时,它返回null。
看代码:
InsereDocumento.xhtml
Choose a PDF file:
<br /> <t:inputFileUpload value="#{inserirBean.uploadedFile}" /> <br />
<h:commandButton value="inserir" action="#{inserirBean.submit}" />
inserirBean.java - 我只把重要的代码放在这里......
private UploadedFile uploadedFile;
public void submit() throws IOException {
String fullPath = FilenameUtils.getFullPath(uploadedFile.getName());
System.out.println("Full Path: " + fullPath);
}
public UploadedFile getUploadedFile() {
return uploadedFile;
}
public void setUploadedFile(UploadedFile uploadedFile) {
this.uploadedFile = uploadedFile;
}
它打印任何内容,FilenameUtils.getFullPath(uploadedFile.getName())返回null
并且完整路径字符串变量是null
.
这里有什么问题?