http://blog.csdn.net/wslovess/article/details/5092898
获取根路径:电脑中磁盘位置
1.private static String getPath(){//获得项目所在根路径
String myPath="";
if ("\\".equals(File.separator))
{
myPath = ServletActionContext.getServletContext().getRealPath("/").replace("/", "\\");
} else if ("/".equals(File.separator))
{
myPath = "/appdata/webapps/tomcat/localhost2/";
}
return myPath;
}
获取根路径:网络访问位置
2. HttpServletRequest request = ServletActionContext.getRequest();
String url = request.getHeader("Referer");
String myurl = url.substring(0, url.lastIndexOf("/"))+"/pdf/Call_Detail_Record"+date+".tar";