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

问题描述 投票:4回答:1

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

getServletContext()方法。getRealPath( “”)

检索路径,服务器返回

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

但是,当客户端运行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,但找不到解决方案。

eclipse websphere-liberty open-liberty
1个回答
5
投票

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

getServletContext()方法。getRealPath( “/”)

代替

getServletContext()方法。getRealPath( “”)

我不确定它是否适用于所有情况,但它在我的机器上运行良好。

© www.soinside.com 2019 - 2024. All rights reserved.