There are two solutions.
Simple way, when there is not context mess:
In the servlet you get the bean using WebApplicationContextUtils.getWebApplicationContext(getServletContext()).getBean("oneSpringBean")
Complex way, when you have custom context scopes:
<bean class="org.springframework.web.context.support.ServletContextAttributeExporter"> <property name="attributes"> <map> <entry key="myAttribute" value-ref="oneSpringBean" /> </map> </property> </bean>
In the servlet you get the bean using getServletContext().getAttribute("myAttribute")
No hay comentarios:
Publicar un comentario