Build an SSH framework with eclipse

Source: Internet
Author: User

Q: What are the three frameworks for SSH and what are their roles?

A: respectively, struts,spring,hibernate.

Struts's role is: is the web layer, its core is the MVC pattern, he can automatically get parameters, automatic type conversion, automatic page jump (the results of the business interface returned to the package sent to the specified view, and by the view to complete the presentation of the results of processing), Another is to do some simple calibration or international work.

The role of spring is to be a business layer, using IOC and AOP, for project decoupling.

Hibernate's role is: The encapsulation of the database

Pre-set up work to be done beforehand:

1. Install JDK, here's not much to say, I'm using jdk1.8

2. Tools to use: Eclipse,mysql, etc.

OK, then we'll start creating the project.

The first step: Create a project called SSH. But to remind you not to forget to check the Web. xml file, see below.

Step Two: Build STRUTS2 environment

First, introduce STRUTS2 's package.

Next you need to modify the Web. xml file Inside Web-inf

Since we're going to introduce spring in a while, so this listener we're here to configure

The third step is to add our Struts.xml file.

Next we need to create an action class named Indexaction.

In the middle, we'll build a DAO class and service class accordingly.

Just the injection, it replaces the previous new object.

Next we will build the JSP file first, we do not write the contents, just to get the process out

Step three: Building the environment for spring and hibernate

First of all, we also need a guide package.

Here our files and source code is not required to come in

The bag is not finished, and it needs a struts2-spring.

As follows:

And then we're going to guide hibernate with the package

We'll be able to inject it with sessionfactory after the hibernate package is done.

Next we write the Applicationcontext.xml file

See mapping files for entity classes I'm just going to give you an example here.

Then we continue to get applicatecontext.xml files.

In that case we need to write a JDBC attribute on our own, so we need to import it in the head

Then we need to create a copy of the Jdbc.properties

Build an SSH framework with eclipse

Related Article

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.