欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

SSH中 Servlet init方法 里面获取到项目根目录

程序员文章站 2022-04-23 17:51:18
...
 public void init(ServletConfig config) throws ServletException {
	super.init(config);
	try {
	   String basePath = org.springframework.web.util.WebUtils.getRealPath(
		    this.getServletContext(), "/");
	   
	} catch (FileNotFoundException e) {
	    // TODO Auto-generated catch block
	    e.printStackTrace();
	}
    }