Spring Learning Note 01

Source: Internet
Author: User

A forum login module to explain how to use spring

Although the login function is simple, although the module is small, it basically includes the operation of the general Web application. Covers persistent layer data access (database related operations), Business Layer transaction management (database operations rollback, etc.), presentation layer MVC, and other enterprise operations.

Introduction to Instance Features

The basic process of landing is not elaborate, to say is the successful landing, record the user's success log, update the user's left after the login time and IP, and to add 5 points to the user, and then redirect to the Welcome interface, the page flow as follows

The persistence layer has two DAO classes, namely Userdao and Loginlogdao, corresponding to a business class UserService in the business layer, with a Logincontroller class and two JSP pages in the presentation layer, is landing page login.jsp and welcome on the interface main.jsp.
Let's take a look at the timing diagram for the entire process.

1. The user first accesses login.jsp, returns the login page with username/password form;
2. The user enters the user name and the password in the landing page, submits the form to the server, spring responds to the login request according to the configuration call Logincontroller Controller;
3.LoginController calls the Userservice#hasmatchuser () method, UserService internally through the call to the persistence layer Userdao to complete the specific database access operations;
4. If there is no matching user, redirect to the login.jsp page and report the error, otherwise the next step;
5.LoginController calls the Userservice#finduserbyusername () method, loads the matching user object and updates the last login time and login IP;
6.LoginController call Userservice#loginsuccess () method, the login successful business processing: Specifically, first call Userdao#updatelogininfo () to add 5 points for the user, Then create a Loginlog object and use Loginlogdao to insert it into the database;
7. Redirect to the Welcome screen main.jsp.


Development environments that need to be prepared before development
Linux:ubun 14.04 64bitide:intellij Idea 14.03jdk:1.7.40mysql:5.5.44tomcat:7.0.47maven:3.0.5

Spring Learning Note 01

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.