2017-09-26 58 views
0
我以前使用本地環境的Tomcat 9.0

,同時採用的getServletContext()。getRealPath( 「」)在WebSphere Application Server返回null自由

的getServletContext()。getRealPath( 「」)

檢索路徑,服務器返回

.... metadata.plugins \ org.eclipse.wst.server.core \ TMP1 \ wtpwebapps \ Web應用程序\

然而,隨着客戶端運行WebSphere Application Server的自由,我安裝我的機器上是相同的,但在Tomcat中返回的路徑相同的代碼,返回

在WebSphere環境。你能幫我理解爲什麼發生這種情況,我將如何在Websphere環境中獲得路徑。我也檢查了以下鏈接https://www.ibm.com/developerworks/community/forums/html/topic?id=eb04c8ae-02d4-421b-af2c-2ef626a3db1b&ps=50&tags=&query=&filter=&sortBy=&order=asc,但無法找到解決方案。

+0

代碼如何部署到兩者? – nitind

+0

它沒有部署在我已經停止Tomcat暫時運行Websphere。多數民衆贊成在如何我可以檢查它 –

回答

0

我確實在Websphere環境中獲得了路徑。在WebSphere中,就要求我們必須給予一個 '/',而不是空字符串即

的getServletContext()。getRealPath( 「/」)

,而不是

getServletContext()。getRealPath(「」)

我不確定它是否適用於所有情況,但它在我的機器中正常工作。

+0

是的,此外,你將需要擴大戰爭,所以要麼設置''如果你只是把應用程序放在'dropin'文件夾,或擴大戰爭'apps'文件夾並將它們添加到'server.xml'。如果應用程序將作爲存檔保存在打包的表單中,它將不起作用。 – Gas

相關問題