Thanks for your suggest.
According to what it is written on LanguageReference document:
...The default BeanFactory used by the DispatcherServlet is the XmlBeanFactory and the
DispatcherServlet will on initialization look for a file named [servlet-name]-servlet.xml in the WEB-INF
directory of your web application.....
I have renamed servlet-context.xml to example-servlet.xml.
"example" is the name of DispatcherServlet.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<!--
- Application context definition for "example" DispatcherServlet.
-->
<beans>
<bean name="/test" class="web.XmlController"/>
<bean id="xmlController" class="web.XmlController" >
<property name="procedura"><ref bean="listeManager"/></property>
</bean>
</beans>
Code:
public class XmlController implements Controller, InitializingBean {
private Liste procedura;
public void setProcedura(Liste procedura) {
this.procedura = procedura;
}
public ModelAndView handleRequest(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String nomeProcedura = request.getParameter("procedura");
System.out.println("nomeProcedura: "+nomeProcedura);
if (nomeProcedura.equals("LISTA_TRASFERIMENTI")) {
Liste procedura = new ListeImpl();
Document document = procedura.xmlListaTrasferimenti();
String strDocument = document.asXML();
PrintWriter out = response.getWriter();
}
return new ModelAndView("/test.jsp");
}
public void afterPropertiesSet() throws Exception {
if (procedura == null)
throw new ApplicationContextException("Must set procedura bean property on " + getClass());
}
}
But not run.
A piece of stack trace is :
Code:
INFO: Destroying singletons in factory {org.springframework.beans.factory.suppor
t.DefaultListableBeanFactory defining beans [/test,xmlController]; parent: org.s
pringframework.beans.factory.support.DefaultListableBeanFactory defining beans [
propertyConfigurer,myDataSource,trasferimentiDao,cartellaInfermieristicaDao,list
eManager,cartellaInfermieristicaManager]; root of BeanFactory hierarchy}
28-giu-2005 16.08.06 org.springframework.web.servlet.FrameworkServlet initServle
tBean
GRAVE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name '/test' defined in ServletContext resource [/WEB-INF/example-servlet.xml]
: Initialization of bean failed; nested exception is org.springframework.context
.ApplicationContextException: Must set procedura bean property on class web.XmlC
ontroller
org.springframework.context.ApplicationContextException: Must set procedura bean
property on class web.XmlController
at web.XmlController.afterPropertiesSet(XmlController.java:73)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:937)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:334)
Indicating that ApplicationContext is not loaded.
Katentim, have you any idea?
Thanks a lot.