<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

    后臺(tái)實(shí)現(xiàn)類:

     

    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;
        }

    }


     

    前臺(tái)實(shí)現(xiàn):Myfaces

     

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

     

     

    后臺(tái)管理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 閱讀(390) 評(píng)論(0)  編輯  收藏 所屬分類: JSF
    主站蜘蛛池模板: 亚州免费一级毛片| 黄网站色视频免费在线观看的a站最新| xxxxwww免费| 亚洲国产综合第一精品小说| 亚洲毛片在线免费观看| 亚洲精品无码久久毛片波多野吉衣| 久久国产色AV免费看| 亚洲精品在线免费观看视频| 久久成人国产精品免费软件| 色婷五月综激情亚洲综合| 24小时免费直播在线观看| 亚洲熟妇av午夜无码不卡| 国产高清免费观看| eeuss影院ss奇兵免费com| 亚洲精品成人无码中文毛片不卡| 免费成人在线视频观看| 亚洲精品亚洲人成在线麻豆| 成人免费一区二区三区在线观看| 亚洲高清国产拍精品熟女| 免费在线一级毛片| A片在线免费观看| 亚洲伊人久久大香线蕉影院| 精品剧情v国产在免费线观看| 又长又大又粗又硬3p免费视频 | 一级做a爰片性色毛片免费网站| 亚洲伊人成无码综合网 | 亚洲国产精品碰碰| 成全在线观看免费观看大全| 亚洲国产成人精品无码一区二区 | 午夜精品一区二区三区免费视频| 亚洲AV无码成人专区| 免费又黄又爽又猛的毛片| 色欲A∨无码蜜臀AV免费播| 亚洲综合av一区二区三区不卡| 亚洲精品国产V片在线观看| 一区二区三区在线免费看| 亚洲aⅴ无码专区在线观看春色| 亚洲伊人久久大香线蕉综合图片| 97在线线免费观看视频在线观看| 搜日本一区二区三区免费高清视频| 久久精品亚洲综合一品|