getRealPath(“/”)——这个方法的结果在Tomcat7和Tomcat8中有何不同
getRealPath(“/”)- How does the result of this method differ in Tomcat 7 and Tomcat 8
使用这个方法
getServletContext().getRealPath("/")
returns '\' 在我 运行 我的项目在 Tomcat 7 结束时,而它在 Tomcat 8.
例如,
在Tomcat 7 它returns 为"D:\Tomcat\webapps\project\"
在Tomcat 8 它returns 为"D:\Tomcat\webapps\project"
目前该项目正在生产中,因此我无法更改每个部分的代码(我使用 getRealPath("/")
的地方)。 tomcat关卡有没有way/setting可以解决
此问题已在 9.0.x 和 8.0.x 以及 8.0.19 之后的主干中得到修复。
供您参考,
使用这个方法
getServletContext().getRealPath("/")
returns '\' 在我 运行 我的项目在 Tomcat 7 结束时,而它在 Tomcat 8.
例如,
在Tomcat 7 它returns 为"D:\Tomcat\webapps\project\"
在Tomcat 8 它returns 为"D:\Tomcat\webapps\project"
目前该项目正在生产中,因此我无法更改每个部分的代码(我使用 getRealPath("/")
的地方)。 tomcat关卡有没有way/setting可以解决
此问题已在 9.0.x 和 8.0.x 以及 8.0.19 之后的主干中得到修复。
供您参考,