<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 5,  comments - 7,  trackbacks - 0

    后臺實現類:

     

    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;

    import javax.faces.context.FacesContext;

    import org.apache.myfaces.custom.fileupload.UploadedFile;


    public class Fileupload
    {
        
    private UploadedFile _upFile;
        
    private String _name = "";

       
    public UploadedFile getUpFile()
        
    {
            
    return _upFile;
        }


     

    public void setUpFile(UploadedFile upFile)    
        
    {
            _upFile 
    = upFile;
        }


        
    public String getName()
        
    {
            
    return _name;
        }


        
    public void setName(String name)
        
    {
            _name 
    = name;
        }


        
    public String upload() throws IOException
        
    {
            FacesContext facesContext 
    = FacesContext.getCurrentInstance();
            
    int start=_upFile.getName().lastIndexOf("\\")==-1?_upFile.getName().lastIndexOf("\\"):_upFile.getName().lastIndexOf("\\")+1;
            String file
    =_upFile.getName().substring(start,_upFile.getName().length());
            String path
    =Fileupload.class.getResource("/").getPath().substring(1,Fileupload.class.getResource("/").getPath().length());
            path
    =path.replace("%20"" ")+file;
      
    try {
       FileOutputStream keyFOS 
    = new FileOutputStream(path);
       keyFOS.write(_upFile.getBytes());
       keyFOS.close();
      }
     catch (Exception e) {
       System.out.println(
    "lalala");
      }

      
            facesContext.getExternalContext().getApplicationMap().put(
    "fileupload_bytes", _upFile.getBytes());
            facesContext.getExternalContext().getApplicationMap().put(
    "fileupload_type", _upFile.getContentType());
            facesContext.getExternalContext().getApplicationMap().put(
    "fileupload_name", _upFile.getName());
            
    return path;
        }


    public boolean isUploaded()
        
    {
            FacesContext facesContext 
    = FacesContext.getCurrentInstance();
            
    return facesContext.getExternalContext().getApplicationMap().get("fileupload_bytes")!=null;
        }

    }


     

    前臺實現:Myfaces

     

    <t:inputFileUpload id="fileupload"
                                   value
    ="#{action$fixing.myFile}"         
                                   storage
    ="file"
                                   styleClass
    ="fileUploadInput"
                                   maxlength
    ="200000"/>
          
    <h:commandButton value="#{prompt['Submit']}"
           action
    ="#{action$fixing.sel}" />

     

     

    后臺管理Bean:

    import org.apache.myfaces.custom.fileupload.UploadedFile;

     

    public class FixingAction{

    private UploadedFile myFile;

     

    public UploadedFile getMyFile() {
      return myFile;
     }

     

     

    public void setMyFile(UploadedFile myFile) {
      this.myFile = myFile;
     }


        public String sel(){
           Fileupload file=new Fileupload();

    String path=file.setUpFile(this.myFile);

    System.out.println("文件存放路徑:"+path);

    return null;

      }
    }
    posted on 2008-11-27 11:17 Vincent-chen 閱讀(391) 評論(0)  編輯  收藏 所屬分類: JSF
    主站蜘蛛池模板: 亚洲精品无码久久久久AV麻豆| 美丽姑娘免费观看在线观看中文版 | 97人伦色伦成人免费视频| 亚洲高清免费在线观看| 一级毛片aaaaaa免费看| 亚洲一区二区在线视频| 一级毛片在线观看免费| 中文字幕亚洲第一在线| 1000部国产成人免费视频| 亚洲成aⅴ人在线观看| 无码永久免费AV网站| 亚洲人成人伊人成综合网无码| 女人18特级一级毛片免费视频| 亚洲国产精品成人午夜在线观看 | 亚洲成a人片在线观看无码专区| 日本三级在线观看免费| 久久精品国产亚洲av麻| jjizz全部免费看片| 亚洲欧洲无码AV不卡在线| 四虎影视精品永久免费| 国产男女爽爽爽免费视频| 亚洲AV美女一区二区三区| 97性无码区免费| 久久久久亚洲AV无码去区首| 亚洲精品人成无码中文毛片| 日本高清不卡aⅴ免费网站| 97亚洲熟妇自偷自拍另类图片| 西西大胆无码视频免费| 黄色网址在线免费观看| 久久精品国产96精品亚洲| 日韩精品成人无码专区免费 | 亚洲视频网站在线观看| 四虎影院在线免费播放| 一区二区三区精品高清视频免费在线播放| 亚洲线精品一区二区三区影音先锋 | 国产亚洲精品影视在线产品| 久久综合给合久久国产免费 | 99视频在线免费观看| 亚洲av永久综合在线观看尤物| 免费乱理伦在线播放| 中文字幕无码一区二区免费|