Weblogic的中的文件上傳


在weblogic中在jsp頁面中this.getServletContext().getRealPath("/upload")這樣的寫法是要報錯的
在jsp頁面總你甚至不能使用this.getServletContext(), 而在servlet中.getRealPath("/") 返回的是null

用下面的語句可以在F:\Oracle\Middleware\user_projects\domains\base_domain下創建uploadtemp目錄
(在eclips調試環境中中,改語句會在eclips.exe同級目錄下建立uploadtemp目錄)

   DiskFileItemFactory factory = new DiskFileItemFactory();
   File tempDir=new File("uploadtemp");
   if(!tempDir.exists()){
    
    tempDir.mkdirs();
   }
   factory.setRepository(tempDir);
View Code

使用
File saveDir;
saveDir.getAbsolutePath();
可以獲取對該目錄的引用


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM