原文:有關Linux下request.getRealPath("/")獲取路徑的問題

request.getRealPath 在window獲取的是服務器的根目錄,結尾包含分隔符, 如E: apache tomcat . . bak apache tomcat . . apache tomcat . . webapps test 在Linux下獲取的不含分隔符,如: home weblogic Desktop PTYT ptytNetpay WebRoot 因此需要判斷處理: 最后 ...

2014-08-21 15:26 0 7715 推薦指數:

查看詳情

request.getRealPath()詳解

1、此方法已過時,現在可替換的實現方法有 request.getSession().getServletContext().getRealPath("/") 在Servlet 里用this.getServletContext().getRealPath ...

Wed Apr 10 06:23:00 CST 2013 0 18119
request.getRealPath的替代方法

由於最近使用request.getRealPath發現該方法已經不推薦使用了,查了一后,發現替代方法為request.getSession().getServletContext().getRealPath(File.separator) 如request ...

Tue Mar 14 00:58:00 CST 2017 0 7501
解決request.getSession().getServletContext().getRealPath("/")為null問題

今天把程序部署到服務器,發現異常,FileNotFound異常,很快定位到getServletContext().getRealPath("/");返回空的問題。這個問題通常是傳遞的虛擬路徑不對或者使用war包導致的。而我的程序傳遞的路徑肯定正確,並且部署的時候對.war包做了解壓。對這個問題 ...

Fri Nov 02 22:12:00 CST 2018 0 4194
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM