the compilation of MVC cases
- Database: Temporarily use XML as a database
- Technology
- Servlet + JavaBean + JSP
- Encapsulating data
- In the JSP display
- Parsing xml
-
Environment preparation
- Create a new Web project, import a jar package
- Create a database, create a user.xml file on disk
-
Requirements to complete registration
- Registration Form (case)
- Database (NO)
- Architecture
Servlet + JSP + JavaBean
- Technology
- Parsing XML using DOM4J technology
- Servlet Technology
- Beanutils Technology
- Jstl+el-expression
- Create a new project
- Importing JAR Packages
- Creating a Package structure
-
Step 1 of development
- Write a registered page,
Username, password, confirm password, alias, email, Verification code
- Complete the validation
onsubmit() of the data first
- Cannot be empty, the password and the confirmation password are the same
- The mailbox is formatted correctly (regular expression)
- Send requests, request Servlets, receive data, encapsulate, process data
- displayed on the JSP.
-
MVC development Process
-
C: Control layer (receive requests and parameters sent from the client)
- Receive parameters (Request object)
- For ease of operation (encapsulating data, introspection, beanutils open source tools)
- Own new User (); USER.SETXXX data
- Complete the Code of Business logic (not recommended written in servlet) written in New UserService ();
- Receives the result, sends the displayed data to the JSP through the result. (The result is stored in a domain object)
-
M: Model layer (JavaBean package data, other JavaBean processing business)
- Process business logic According to the registered functionality. (User name can not duplicate, mailbox cannot duplicate)
- Need to return the results.
-
V: View layer (complete display of data)
- To the JSP page, the value of the field is taken from the El expression.
MVC Registration Case
Java Advanced Learning 14th Day--MVC development process