java--获取项目路径

html中获取工程路径:

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

javaScript中获取工程路径

  var localObj = window.location;
  var contextPath = localObj.pathname.split("/")[1];
  var basePath = localObj.protocol+"//"+localObj.host+"/"+contextPath;

java中获取工程路径

String path = ServletActionContext.getRequest().getRealPath(relativePath); 


String projectPath = request.getSession().getServletContext().getRealPath("");

http://my.oschina.net/zb0423/blog/60955

你可能感兴趣的:(工程路径)