Struts + spring + hibernate combination

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.