在Service项目中获取项目绝对路径的方法
1.实现ServletContextAware接口
2.声明成员属性:private ServletContext servletContext;
3.重写setServletContext方法this.servletContext = servletContext
,为ServletContext 赋值
4.获取绝对路径String realPath = servletContext.getRealPath(path);
1.实现ServletContextAware接口
2.声明成员属性:private ServletContext servletContext;
3.重写setServletContext方法this.servletContext = servletContext
,为ServletContext 赋值
4.获取绝对路径String realPath = servletContext.getRealPath(path);