<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
    主站蜘蛛池模板: 精品久久久久亚洲| 日本免费大黄在线观看| 啦啦啦中文在线观看电视剧免费版| 两个人的视频高清在线观看免费| 亚洲视频精品在线观看| 99re在线这里只有精品免费| 无码欧精品亚洲日韩一区| 亚洲成av人无码亚洲成av人| 日本高清不卡aⅴ免费网站| 日本免费中文字幕在线看| 亚洲午夜精品一区二区麻豆| 中文在线观看永久免费| 亚洲人成影院在线无码按摩店| 成在人线av无码免费高潮水| 国产精品亚洲A∨天堂不卡| 美女视频黄的免费视频网页| 亚洲AV福利天堂一区二区三| 免费人成在线观看网站品爱网 | 72pao国产成视频永久免费| 中文字幕在亚洲第一在线| 国产亚洲福利在线视频| a毛片久久免费观看| 日韩a在线观看免费观看| 另类小说亚洲色图| 日本亚洲欧洲免费天堂午夜看片女人员| 成人免费区一区二区三区| 日木av无码专区亚洲av毛片| 久久WWW免费人成人片| 免费夜色污私人影院网站| 亚洲国产成人精品不卡青青草原| 免费一区二区无码视频在线播放| 国产亚洲AV手机在线观看| 污污视频免费观看网站| 亚洲五月综合缴情在线观看| 最近免费中文字幕大全免费版视频| 久久亚洲中文字幕精品一区四| 免费精品一区二区三区第35| 亚洲午夜福利在线视频| 亚洲精品成人片在线播放 | 四虎影视在线永久免费看黄 | 中中文字幕亚洲无线码|