您的位置:首页 > 移动开发

spring3.0以后移除ContextLoaderServlet,使用ContextLoaderListener获取ApplicationContext

2016-07-05 17:01 441 查看
Spring3.0以后就找不到ContextLoaderServlet这个类了。跟了一下包也确实没有ContextLoaderServlet这个类了。

然后想确认一下查看 spring changelog 果然。

Changes in version 3.0.0.M1 (2008-12-05)

----------------------------------------

* revised project layout and build system (module-based sources, bundle repository)

* updated entire codebase for Java 5 code style (generics, varargs, StringBuilder)

* updated to JUnit 4.5 and JRuby 1.1

* removed WebLogic 8.1 and WebSphere 5.1 support

* removed native TopLink API support (superseded by JPA)

* removed Commons Attributes support (superseded by Java 5 annotations)

* removed Jakarta JSTL support for JSP 1.2 (superseded by JSP 2.0)

* removed outdated Struts 1.x Action delegation support
* removed ContextLoaderServlet and Log4jConfigServlet

* deprecated form controller hierarchy in favor of @MVC form object handling

* deprecated JUnit 3.8 test class hierarchy in favor of test context framework

* revised TaskExecutor interface to extend "java.util.concurrent.Executor" now

* introduced Spring EL parser in org.springframework.expression package

* introduced #{...} expression support in bean definitions

* introduced @Value annotation for embedded expression support

* introduced @PathVariable annotation for MVC handler methods

* introduced ShallowEtagHeaderFilter

* introduced AbstractAtomFeedView and AbstractRssFeedView

* introduced default value support for @RequestParam

* introduced @RequestHeader annotation for MVC handler methods

* introduced "spring:url" and "spring:param" JSP tags

现在没法使用ContextLoaderServlet方式获取了。那么建议使用ContextLoaderListener方式获取。

ServletContext sc = request.getSession().getServletContext();
ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(sc);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: