getServletContext().getRealPath
时间: 2024-04-26 08:26:44 浏览: 197
getServletContext().getRealPath方法用于获取当前应用在服务器上物理路径。该方法可以返回一个字符串,包含给定虚拟路径的真实路径。例如,通过传入"/"作为参数,可以获取到当前应用的WebRoot的物理路径。这个路径的格式会根据servlet容器所在的计算机或操作系统而有所不同,但会包含适当的路径分隔符。如果无法转换虚拟路径,则该方法会返回null。使用这个方法可以方便地获取当前应用的物理路径,以便进行文件操作等操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [ServletContext中getRealPath()读取文件、观察servlet运行过程](https://blog.csdn.net/lanadelrey13/article/details/124294263)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [javaweb中 ServletActionContext.getServletContext().getRealPath("")获得服务器路径](https://blog.csdn.net/w405722907/article/details/76687538)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [servlet中getServletContext().getRealPath("/")相关问题收集](https://blog.csdn.net/lzm18064126848/article/details/50011301)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文