Java development: Share some of the springmvc+ibatis+spring framework usage experience

Source: Internet
Author: User

In the near future, instead of doing. NET projects, but using Java as a development language, think about using SPRINGMVC development, because the previous years have used struts1/2+hibernate/ibatis+spring developed projects, so there are some foundation. After seeing some SPRINGMVC's introduction on the net, I made a demo.

This demo will be divided into several to introduce, today, first of all, the most basic framework building and data interaction, transaction processing problems, the next will be integrated Easyui, bootstrap these frameworks and show the results of pagination, validation, and so the demo more practical.

Okay, so let's get to the bottom of this, we'll start by creating a new project with structures like:

The file structure has been explained, then we will talk about the configuration of the problem, about the entity class, DAO Layer and service layer creation, not explained, the map is as follows:

Physical Layer:

DAO Layer:

Ibatis configuration file Layer:

Service Layer:

Note that the annotation function is used here, so you can refer to the explanations on the web.

Next, let's talk about the controller layer :

This base class is a way to encapsulate some common operations.

Controller layer:

Note that the control layer avoids the business code as much as possible, in order to make the structure look as clear.

The database I'm using is MySQL, and here's the SQL statement that builds the table:

Once the database is built, we need to connect to the project, which is configured as follows:

JDBC Configuration file:

Next is the more important configuration file:

The comments I gave in these two profiles are more detailed.

Before configuring a transaction, you have encountered an invalid problem, the reason is:

SPRINGMVC configuration, scan the controller but do not scan the service,

In spring configuration, the controller is not scanned.

The service's transaction is invalidated because of its load order problem.

In addition, there is a Web. XML Configuration :

The front-end page is the form form that submits data to the controller layer, performing business processing. The list page is also displayed from the controller layer data to the data.

OK, here's the simple one today, here are two front page:

Well, today is the point, next time, I will integrate the Easyui framework, and then share with you, welcome interested people to join the exchange.

Java development: Share some of the springmvc+ibatis+spring framework usage experience

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.