springMvc獲取servletContext
// 001 WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext(); ServletContext servletContext = webApplicationContext.getServletContext(); // 002 這個可以是2.5規范下面使用 RequestContextUtils.getWebApplicationContext(request).getServletContext(); // 003 這個是3.0規范的; ServletContext context = req.getServletContext();