当前位置: 代码迷 >> Java Web开发 >> 怎么在org.apache.myfaces.custom.fileupload.UploadedFile获取上穿文件的路径名
  详细解决方案

怎么在org.apache.myfaces.custom.fileupload.UploadedFile获取上穿文件的路径名

热度:621   发布时间:2016-04-17 13:38:14.0
如何在org.apache.myfaces.custom.fileupload.UploadedFile获取上穿文件的路径名?
我现在无法在客户端获得上传文件路径名
页面代码:    
<div   id= "fileUploadDiv "   style= "display:none; ">
<h:form   id= "form_fileUpload "   enctype= "multipart/form-data ">
<h:outputText   value= "Choose   File "   />
<t:inputFileUpload   id= "fileupload "
value= "#{fileUploadMgrBean.upFile} "   storage= "file "   styleClass= " "
required= "true "   maxlength= "200000 "   />
<h:commandButton   value= "OK "   action= "#{fileUploadMgrBean.upload} ">
<h:inputHidden   id= "DeviceType "   value= "3000MX "   />
<h:inputHidden   id= "DeviceIP "   value= "#{deviceInfoMgrBean.infoByName.IP} "   />
</h:commandButton>
</h:form>
</div>
javabean代码
public   class   FileUploadMgrBean
{
public   UploadedFile   getUpFile()
{
logger.info( "[ACTION]   -   getUpFile() ");
return   _upFile;
}
public   void   setUpFile(UploadedFile   upFile)
{
System.out.println( "_upFile   =   "+upFile);
_upFile   =   upFile;
}
public   String   upload()   throws   IOException
{
logger.info( "[UPLOAD]   -   filename: "   +   _upFile.getName());//这里只能获取到文件名没有路径名,想在客户端获得文件的路径
}
}

------解决方案--------------------
logger.info( "[UPLOAD] - filename: " + _upFile.getPath());
  相关解决方案