springMvc获取servletContext


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();

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM