我一直在使用這個(gè)“ServletContext.getRealPath("")" 直到 Tomcat8,我得到了以斜線結(jié)尾的返回字符串路徑。For Example ServletContext.getRealPath("")+"resources" will return /home/company/eclipse_workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/Project_Title/resources但是當(dāng)我嘗試使用 Tomcat 9.0 時(shí),我得到了沒有斜杠的路徑For Example ServletContext.getRealPath("")+"resources" will return /home/company/eclipse_workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/Project_Titleresources缺少“Project_Title”后的斜杠。此異常僅在部署 (.WAR) 之后發(fā)生。本地沒有問題。希望有人能幫助我。
ServletContext().getRealPath("") 返回不以 / 結(jié)尾的路徑
函數(shù)式編程
2023-06-21 16:06:57