【问题标题】:getRealPath(“/”)- How does the result of this method differ in Tomcat 7 and Tomcat 8getRealPath(“/”) - 此方法的结果在 Tomcat 7 和 Tomcat 8 中有何不同
【发布时间】:2015-04-10 10:01:51
【问题描述】:

使用这种方法

getServletContext().getRealPath("/")

当我在 Tomcat 7 中运行我的项目时,最后返回“\”,而它在 Tomcat 8 中无法正常工作。

例如,

在 Tomcat 7 中,它返回为“D:\Tomcat\webapps\project\”

在 Tomcat 8 中,它返回为“D:\Tomcat\webapps\project”

目前该项目正在生产中,所以我无法更改每个部分的代码(我使用getRealPath("/"))。有没有办法/设置在 tomcat 级别来解决它。

【问题讨论】:

    标签: web-services jsp tomcat web-applications tomcat8


    【解决方案1】:

    此问题已在 9.0.x 的主干和 8.0.19 及更高版本的 8.0.x 中得到修复。

    供您参考,

    https://bz.apache.org/bugzilla/show_bug.cgi?id=57556

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-21
      • 1970-01-01
      相关资源
      最近更新 更多