【发布时间】:2010-03-23 14:44:58
【问题描述】:
我有一个 portlet 应用程序。它是使用 Spring 框架 IoC 容器配置的。我正在使用 org.springframework.web.context.ContextLoaderListener 来加载我的上下文。
我有一个根级别的应用程序上下文 (applicationContext.xml) 和一个特定于 portlet 的上下文 (MyPortlet-portlet.xml)。
我有一个 org.springframework.web.portlet.DispatcherPortlet 类型的 portlet,它连接到一个控制器。在控制器中,我想访问我在 portlet 特定上下文中定义的 bean 之一(例如,id 为“myBean”的 bean)。我试过了
MyBean mybean = (MyBean)PortletApplicationContextUtils.getWebApplicationContext(
getPortletContext()).getBean("myBean")
但是,这里只有我的应用程序上下文中的 bean 可用 - 我的 portlet 特定上下文中的任何 bean 都不可用。
有没有办法在我的 portlet 特定上下文中访问 bean?
谢谢
【问题讨论】:
标签: java spring spring-mvc portlet