超市訂單管理系統(1)


注:項目的隨筆來自狂神說的原生web開發的學習。

1.項目准備工作(到這個階段,想必java的相關環境已經熟練配置了,有問題可聯Q,相互交流,相互進步:810806242)

  (1)創建一個maven項目,使用webapp模板

  (2)在idea的該項目中配置tomcat

  (3)測試項目環境,運行tomcat后,在瀏覽器打開index.html頁面,出現hello world,環境配置成功

  (4)在pom.xml中導入jsp,servlet,連接數據庫的依賴,jstl,standard依賴

 1 <dependency>
 2       <groupId>javax.servlet</groupId>
 3       <artifactId>servlet-api</artifactId>
 4       <version>2.5</version>
 5     </dependency>
 6     <dependency>
 7       <groupId>javax.servlet.jsp</groupId>
 8       <artifactId>javax.servlet.jsp-api</artifactId>
 9       <version>2.3.3</version>
10     </dependency>
11     <dependency>
12       <groupId>mysql</groupId>
13       <artifactId>mysql-connector-java</artifactId>
14       <version>5.1.47</version>
15     </dependency>
16     <dependency>
17       <groupId>javax.servlet.jsp.jstl</groupId>
18       <artifactId>jstl-api</artifactId>
19       <version>1.2</version>
20     </dependency>
21     <dependency>
22       <groupId>taglibs</groupId>
23       <artifactId>standard</artifactId>
24       <version>1.1.2</version>
25     </dependency>

  (5)創建項目目錄結構(可能以后會根據個人需求增加相關的目錄結構以及文件,但是這幾個是基本的)

    

  (6)編寫實體類(bean),進行ORM映射(數據庫表-類之間的映射,注意:實體類的編寫要與數據庫字段相對應,數據庫文件鏈接:https://pan.baidu.com/s/1Cqyw3_vcDBHz7UDft8rCDQ提取碼:6666 ),以bill表為例,bill表字段為

bill表對應的實體類代碼(實體類中無非是,對應字段的變量聲明,加上構造器和get,set方法),其余數據庫表同理。

  1 package com.xiaoma.pojo;
  2 
  3 import java.util.Date;
  4 
  5 public class Bill {
  6     private int ID;//主鍵ID
  7     private String BillCode;//賬單編碼
  8     private String ProductName;//商品名稱
  9     private String ProductDesc;//商品描述
 10     private String ProductUnit;//商品單位
 11     private float ProductCount;//商品數量
 12     private float TotalPrice;//商品總額
 13     private int IsPayment;//是否支付
 14     private int CreatedBy;//創建者
 15     private Date CreationDate;//創建時間
 16     private int ModifyBy;//修改者
 17     private Date ModifyDate;//修改時間
 18     private int ProviderId;//供應商ID
 19 
 20     public Bill() {
 21     }
 22 
 23     public Bill(int ID, String billCode, String productName, String productDesc, String productUnit,
 24                 float productCount, float totalPrice, int isPayment, int createdBy, Date creationDate,
 25                 int modifyBy, Date modifyDate, int providerId) {
 26         this.ID = ID;
 27         BillCode = billCode;
 28         ProductName = productName;
 29         ProductDesc = productDesc;
 30         ProductUnit = productUnit;
 31         ProductCount = productCount;
 32         TotalPrice = totalPrice;
 33         IsPayment = isPayment;
 34         CreatedBy = createdBy;
 35         CreationDate = creationDate;
 36         ModifyBy = modifyBy;
 37         ModifyDate = modifyDate;
 38         ProviderId = providerId;
 39     }
 40 
 41     public int getID() {
 42         return ID;
 43     }
 44 
 45     public void setID(int ID) {
 46         this.ID = ID;
 47     }
 48 
 49     public String getBillCode() {
 50         return BillCode;
 51     }
 52 
 53     public void setBillCode(String billCode) {
 54         BillCode = billCode;
 55     }
 56 
 57     public String getProductName() {
 58         return ProductName;
 59     }
 60 
 61     public void setProductName(String productName) {
 62         ProductName = productName;
 63     }
 64 
 65     public String getProductDesc() {
 66         return ProductDesc;
 67     }
 68 
 69     public void setProductDesc(String productDesc) {
 70         ProductDesc = productDesc;
 71     }
 72 
 73     public String getProductUnit() {
 74         return ProductUnit;
 75     }
 76 
 77     public void setProductUnit(String productUnit) {
 78         ProductUnit = productUnit;
 79     }
 80 
 81     public float getProductCount() {
 82         return ProductCount;
 83     }
 84 
 85     public void setProductCount(float productCount) {
 86         ProductCount = productCount;
 87     }
 88 
 89     public float getTotalPrice() {
 90         return TotalPrice;
 91     }
 92 
 93     public void setTotalPrice(float totalPrice) {
 94         TotalPrice = totalPrice;
 95     }
 96 
 97     public int getIsPayment() {
 98         return IsPayment;
 99     }
100 
101     public void setIsPayment(int isPayment) {
102         IsPayment = isPayment;
103     }
104 
105     public int getCreatedBy() {
106         return CreatedBy;
107     }
108 
109     public void setCreatedBy(int createdBy) {
110         CreatedBy = createdBy;
111     }
112 
113     public Date getCreationDate() {
114         return CreationDate;
115     }
116 
117     public void setCreationDate(Date creationDate) {
118         CreationDate = creationDate;
119     }
120 
121     public int getModifyBy() {
122         return ModifyBy;
123     }
124 
125     public void setModifyBy(int modifyBy) {
126         ModifyBy = modifyBy;
127     }
128 
129     public Date getModifyDate() {
130         return ModifyDate;
131     }
132 
133     public void setModifyDate(Date modifyDate) {
134         ModifyDate = modifyDate;
135     }
136 
137     public int getProviderId() {
138         return ProviderId;
139     }
140 
141     public void setProviderId(int providerId) {
142         ProviderId = providerId;
143     }
144 }

 (現在時間2021年10月15日晚21:27,欲知后事如何,請聽下回分解)

 

 整個項目的源碼:

鏈接:https://pan.baidu.com/s/1IOm208Ih9Hb9k1pq_k8srA
提取碼:6666


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM