java servletcontext 获得路径_ServletContext获取项目真实路径

import javax.servlet.ServletContext;

import org.springframework.web.context.ServletContextAware;

/**

* @author Administrator

*

*/

public class PayUtil implements ServletContextAware{

public ServletContext context ;

public static String PATH = "";

/* (non-Javadoc)

* @see org.springframework.web.context.ServletContextAware#setServletContext(javax.servlet.ServletContext)

*/

public void setServletContext(ServletContext context) {

this.context = context;

}

public void myinit(){

PayUtil.PATH = context.getRealPath("");

}

}

PayUtil.PATH = D:\work\apache-tomcat-7.0.52\webapps\pra

时间: 07-22

你可能感兴趣的:(java,servletcontext,获得路径)