I. Create a database (environment MySQL)
Database Name (abbreviated), Character (UTF-8 Unicode)
Ii. Creating an MVC structure
Create a Java/com.itemname.module (demo) package
Create folder under Package Controller, Model, service child package
III. preparation of the model layer
New Java Class:customer
public class Customer {
Private long CustomerID;
Private String Name;
Private String contact;
Private String telephone;
Private String Email;
Private String Remark;
Getter and Setter
}
Create the appropriate database table and insert the demo data
Third, write the controller layer
List interface: Get:/customer
Query action: Post:/customer_search--
Detail interface: Get:/customer_show?id={id}
New interface: Get:/customer_create
New action: Post:/customer_create
Editing interface: Get:/customer_edit?id={id}
Edit action: Put:/customer_edit?id={id}
Delete action: Delete:/customer_delete?id={id}
Corresponds to 5 servlets
Customerservlet, Customershowservlet, Customercreateservlet, Customereditservlet, Customerdeleteservlet
Create a servlet.
@WebServlet ("/customer_create")
public class Customercreateservlet extends HttpServlet {
/**
* Process Create customer request
*/
protected void DoPost (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException {
Todo
}
/**
* Enter Create customer interface
*/
protected void doget (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException {
Todo
}
}
Iv. preparation of the service layer
public class CustomerService {
/**
* Get Customer List
*/
Public list<customer> getcustomerlist (String keyword) {
Todo
return null;
}
/**
* Get Customer
*/
Public Customer GetCustomer (long id) {
Todo
return null;
}
/**
* Create Customer
*/
public boolean CreateCustomer (map<string,object> fieldMap) {
Todo
return false;
}
/**
* Update Customer
*/
public Boolean UpdateCustomer (long ID, map<string,object> fieldMap) {
Todo
return false;
}
/**
* Delete Customer
*/
public Boolean deletecustomer (long id) {
Todo
return false;
}
}
Third, the initial business development