String filePath = request.getSession().getServletContext().getRealPath("/");请问这句话返回的路径是什么,解释下getRealPath("/")函数中的"/"表示什么意思,

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/04 07:59:16

String filePath = request.getSession().getServletContext().getRealPath("/");请问这句话返回的路径是什么,解释下getRealPath("/")函数中的"/"表示什么意思,
String filePath = request.getSession().getServletContext().getRealPath("/");
请问这句话返回的路径是什么,解释下getRealPath("/")函数中的"/"表示什么意思,

String filePath = request.getSession().getServletContext().getRealPath("/");请问这句话返回的路径是什么,解释下getRealPath("/")函数中的"/"表示什么意思,
request.getSession().getServletContext() 获取的是Servlet容器对象,相当于tomcat容器了.getRealPath("/") 获取实际路径,“/”指代项目根目录,所以代码返回的是项目在容器中的实际发布运行的根路径如:I:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\UMPWeb_20131230\