<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
    主站蜘蛛池模板: 亚洲同性男gay网站在线观看| 亚洲乱码日产精品一二三| 亚欧人成精品免费观看| 亚洲中文字幕一区精品自拍| 可以免费观看一级毛片黄a| a毛片免费播放全部完整| 亚洲Av高清一区二区三区| 亚洲精品NV久久久久久久久久| 中文字幕视频在线免费观看| 亚洲国产成人精品无码区在线秒播| 国产大片免费观看中文字幕| 今天免费中文字幕视频| 亚洲AV无码一区二区三区性色 | 成年人免费网站在线观看| WWW国产成人免费观看视频| 亚洲人成在线免费观看| 区三区激情福利综合中文字幕在线一区亚洲视频1 | 亚洲AV无码国产精品麻豆天美| 国色精品卡一卡2卡3卡4卡免费| 九九综合VA免费看| 亚洲色最新高清av网站| 久久亚洲AV午夜福利精品一区| 国产国产人免费人成免费视频| 中文字幕免费观看| 一区二区三区视频免费观看| 亚洲综合无码无在线观看| 亚洲成AV人片在线观看WWW| 国产伦一区二区三区免费| 免费A级毛片无码A∨免费| EEUSS影院WWW在线观看免费| 精品国产日韩久久亚洲| 亚洲网站在线观看| 亚洲女同成人AⅤ人片在线观看| 成人免费男女视频网站慢动作| 中文字幕免费观看| 三年片在线观看免费西瓜视频| 国产亚洲精品美女| 亚洲熟妇AV一区二区三区宅男| 亚洲无圣光一区二区| 亚洲成a人片77777老司机| 亚洲精品字幕在线观看|