当我使用DispatcherServlet时,我得到一个java.lang.IllegalStateException:找不到WebApplicationContext:没有注册ContextLoaderListener? 我使用DelegatingFilterProxy过滤器时出错.因此我删除了DispatcherServlet,现在我使用ContextLoaderListener,我的Spring应用程序加载正常.但是,我有一个非常重要的bean的问题:
<context:component-scan base-package="com.mydomain"/>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors">
<list>
<ref bean="openSessionInViewInterceptor" />
</list>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
这个bean不再有效,我的@Controller都不再是URL映射了.如果我切换回使用DispatcherServlet,没问题(除了我的过滤器再次没用).如何从ContextLoaderListener中正确加载此bean ?
干杯
聂
ska*_*man 22
同时需要ContextLoaderListener 和对DispatcherServlet-错误消息没有告诉你删除的servlet.
为了澄清Spring在这里做了什么,DispatcherServlet创建它自己的ApplicationContext(通常使用xxx-servlet.xml),但是你在web.xml中配置的任何Spring Filters都无法访问servlet ApplicationContext.
在ContextLoaderListener创建第二ApplicationContext(与整个Web应用程序相关联),并用servlet的链接本身ApplicationContext,使过滤器和servlet来通过Spring沟通.
| 归档时间: |
|
| 查看次数: |
7576 次 |
| 最近记录: |