Two examples of STRUTS + spring + hibernate, one is myusers in chapter 2 of spring live, and the other is wiring your web application with open source Java (this document includes Chinese and English on the Internet) here I name it sshtest. After creating and debugging the two projects in myeclipse, I can see that the two projects are a little different when combining Struts, spring, and hibernate. Below are three configuration files (web. XML, struts-config.xml, applicationcontext. XML,) to see their differences:
The myusers web. XML does not introduce anything special.
Sshtest web. xml:
Pass:
<Listener>
<Listener-class> org. springframework. Web. Context. contextloaderlistener </listener-class>
</Listener -->
Or:
<Servlet>
<Servlet-Name> springcontextservlet </servlet-Name>
<Servlet-class> org. springframework. Web. Context. contextloaderservlet </servlet-class>
<Load-on-startup> 1 </load-on-startup>
</Servlet>
The Web Container automatically loads the/WEB-INF/applicationcontext. XML to initialize the applicationcontex t instance;
You can also use
<Context-param>
<Param-Name> contextconfiglocation </param-Name>
<Param-value>/WEB-INF/applicationcontext-*. xml </param-value>
</Context-param>
Load the spring configuration file with the specified name path to the Web container.
Struts-config.xml for myusers
Pass
<Plug-in classname = "org. springframework. Web. Struts. contextloaderplugin">
<Set-Property = "contextconfiglocation"
Value = "/WEB-INF/applicationcontext. XML,
WEB-INF/action-servlet.xml "/>
</Plug-in>
To load the spring configuration file.
The struts-config.xml of sshtest has nothing special.
The applicationcontext. xml of the two projects are similar.
From the above we can see that you can use web. XML to make Web containers load spring, you can also use struts-config.xml to make Web containers load spring.