// 获取ServletContext对象
ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
// 获取项目根目录的真实路径
String servletRealPath = servletContext.getRealPath("/userfiles");
// 获取ServletContext对象
ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
// 获取项目根目录的真实路径
String servletRealPath = servletContext.getRealPath("/userfiles");