Controller:
1.Struts2:
String path = ServletActionContext.getServletContext().getRealPath(UPLOADDIR);
2.SpringMVC:
String path1 = request.getSession().getServletContext().getRealPath("/videos/download");
3.Servlet:
String path = getServletContext().getRealPath("/videos/newvideos");
JSP:
<%=request.getContextPath()%>
${pageContext.request.contextPath }
转载于:https://my.oschina.net/u/2617871/blog/1542160
