getServletContext().getRealPath和${pageContext.request.contextPath}

String path =
getServletContext().getRealPath("/WEB-INF/new_words.txt");

输出:pathD:\IdeaProjects\itcaststore\target\itcaststore-1.0-SNAPSHOT\WEB-INF\new_words.txt

${pageContext.request.contextPath}:定位webapp文件夹

上一篇:Tomcat中使用servletContext


下一篇:07-Javaweb中 的Context