Integrate SSH manually

Source: Internet
Author: User

In the SSH framework, spring and Hibernate are lightweight. On the one hand, both frameworks do not depend on applications.ProgramThe server can run in a Java environment. On the other hand, the classes we write by ourselves do not need to inherit the classes in the spring or Hibernate framework (of course, there may be dependencies when spring and Hibernate are integrated ), struts is a heavyweight framework. On the one hand, Struts uses Servlet technology, while servlet relies on application servers (such as Tomcat ), on the other hand, the action and actionform classes written by ourselves depend on the action and actionform classes of struts. Therefore, these three frameworks must be used simultaneously in web projects. The integration steps are as follows.

1. Create a WEB Project

2. Introduce the required jar.

The required jar package includes the JDBC driver package, Struts core jar, third-party jar imported by it, Hibernate core jar, third-party jar imported by it, spring core jar, and third-party jar imported by it, third-party jar packages can be introduced selectively. Generally, you can use any function to introduce corresponding jar packages. For example, spring usually introduces spring. jar, log4j. jar, commons-logging.jar, aspectjrt. jar, aspectjweaver. jar. We can create our own jar package Library (User libraries) so that we can introduce the jar package in future projects. The procedure is as follows:

1) Go to Windows> preferences> JAVA> build path> userlibraries> New and add the required jar to introduce the newly added user library, as shown in:

 

2) Right-click the project and choose Properties> JAVA build path> libraries> Add library> userlibraries> introduce the jar package library we just created. As shown in:

3) shows the Project Introduction effect (of course, these jar packages can also be directly copied to webroot/Web-info/LIB ):

3. The configuration file required to establish the framework.

Web. the XML file (under webroot/webinfo) has been created when a web project is created. Other configuration files include applicationcontext. XML, hibernate. cfg. XML and struts-config.xml, which we can copy directly from previous projects and then make some modifications.

4. Use SSH to write the MVC Architecture Program

For the integration of these three frameworks, we often deal with the action class manually written by struts, The actionservlet implemented by struts, The beanfactory class of spring, and the sessionfactory class of hibernate, in the future, we will continue to learn how it works through them, and be more familiar with the SSH environment.

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.