您的位置:首页 > 其它

ServletContext获取项目真实路径

2015-07-24 09:01 274 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: