标签:
1、
JSP 页面中:
<br/>
(1) : <%=request.getContextPath()%>
<br/>
(2) : <%=request.getServletContext().getRealPath("/")%>
<br/>
(3) : <%=request.getServletContext().getRealPath("")%>
输出为:
(1) : /Html5_Video_Simple_01
(2) : ...\workspace__MyEclipse2013\.metadata\.me_tcat7\webapps\Html5_Video_Simple_01\
(3) : ...\workspace__MyEclipse2013\.metadata\.me_tcat7\webapps\Html5_Video_Simple_01
2、
servlet中:
System.out.println("servlet(1) : "+this.getServletContext().getContextPath());
System.out.println("servlet(2) : "+this.getServletContext().getRealPath("/"));
System.out.println("servlet(3) : "+this.getServletContext().getRealPath(""));
输出为:
servlet(1) : /Html5_Video_Simple_01
servlet(2) : ...\workspace__MyEclipse2013\.metadata\.me_tcat7\webapps\Html5_Video_Simple_01\
servlet(3) : ...\workspace__MyEclipse2013\.metadata\.me_tcat7\webapps\Html5_Video_Simple_01
标签:
原文地址:http://www.cnblogs.com/codeskilla/p/4986758.html