getServletContext()。getRealPath(“”)在WebSphere Application Server Liberty中返回null

Jud*_*cks 4 eclipse websphere-liberty open-liberty

我以前在本地环境中使用Tomcat v9.0,同时使用

getServletContext()。getRealPath(“”)

检索路径,服务器返回

.... metadata.plugins \ org.eclipse.wst.server.core \ tmp1 \ wtpwebapps \ WebApp \

但是,当客户端运行WebSphere Application Server Liberty时,我在机器上安装了相同的软件,但是在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,但找不到解决方案。

Jud*_*cks 5

我确实在Websphere环境中获得了成功。在Websphere中,要求我们必须给出一个'/'而不是空字符串,即

getServletContext()。getRealPath(“ /”)

代替

getServletContext()。getRealPath(“”)

我不确定在所有情况下是否都适用,但是在我的机器上工作正常。