1.1学习目标
[外链图片转存失败(img-gVt39HaC-1563411829375)(img\firstPage.png)]
1.2 index需求分析
1): 展示特价商品的信息
2): 展示热卖商品的信息
3): 显示当前最新的的公告列表
4): 显示当前最新的的新闻列表
1.3 页面原型
[外链图片转存失败(img-FVlK4yoP-1563411829378)(img\图片1.png)]
1.4 流程图
[外链图片转存失败(img-nWnuhalX-1563411829379)(img\ebuy_news_product_notices.png)]
1.5 数据库信息
(t_notice)
列名 | 数据类型(精度范围) | 允许空 | 约束条件 | |
---|---|---|---|---|
主键列 | id | int | 否 | 主键,自动增长 |
标题 | title | varchar(50) | 是 | |
内容 | content | text | 是 | |
创建时间 | createTime | datetime | 是 |
(t_news)
列名 | 数据类型(精度范围) | 允许空 | 约束条件 | |
---|---|---|---|---|
主键列 | id | int | 否 | 主键,自动增长 |
标题 | title | varchar(50) | 是 | |
内容 | content | text | 是 | |
创建时间 | createTime | datetime | 是 |
(t_product)
列名 | 数据类型(精度范围) | 允许空 | 约束条件 | |
---|---|---|---|---|
主键列 | id | int | 否 | 主键,自动增长 |
商品描述 | description | varchar(2000) | 否 | |
是否热门 | hot | int | 否 | 1=是,0=否 |
热门时间 | hotTime | datetime | 是 | |
商品名称 | name | varchar(50) | 是 | |
商品价格 | price | int | 否 | |
商品图片 | proPic | varchar(255) | 是 | |
是否特价 | specialPrice | int | 否 | 1=是,0=否 |
特价时间 | specialPriceTime | datetime | 是 | |
商品库存 | stock | int | 否 | |
商品大分类ID | bigTypeId | int | 是 | 外键,t_bigtype表的主键 |
商品小分类ID | smalltypeId | int | 是 | 外键,t_smalltype表的主键 |
二 实现特价商品信息
2.1 Web.xml 配置
<servlet>
<servlet-name>index</servlet-name>
<servlet-class>com.xxx.controller.InitController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>index</servlet-name>
<url-pattern>/index</url-pattern>
</servlet-mapping>
想要更多资料可以加本人微信mageit
2.2 编写对应实体类
package com.xxx.vo;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.xxx.vo.OrderProduct;
//商品实体类
public class Product {
private int id; // id
private String name;// 商品名称
private int price; // 价钱
private int hot; //商品热度
private Date hotTime;//商品热度时间
private int stock; //库存
private String proPic; //商品路劲
private String description;//商品描述
private int specialPrice; //特价的
private Date specialPriceTime;//特价时间
private ProductBigType bigType;//所属大类型的
private ProductSmallType smallType;//所属小类型的
private List<OrderProduct> orderProductList=new ArrayList<OrderProduct>();//中间表
public List<OrderProduct> getOrderProductList() {
return orderProductList;
}
public void setOrderProductList(List<OrderProduct> orderProductList) {
this.orderProductList = orderProductList;
}
public Product() {
// TODO Auto-generated constructor stub
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public int getHot() {
return hot;
}
public void setHot(int hot) {
this.hot = hot;
}
public Date getHotTime() {
return hotTime;
}
public void setHotTime(Date hotTime) {
this.hotTime = hotTime;
}
public int getStock() {
return stock;
}
public void setStock(int stock) {
this.stock = stock;
}
public String getProPic() {
return proPic;
}
public void setProPic(String proPic) {
this.proPic = proPic;
}
public Date getSpecialPriceTime() {
return specialPriceTime;
}
public void setSpecialPriceTime(Date specialPriceTime) {
this.specialPriceTime = specialPriceTime;
}
public ProductBigType getBigType() {
return bigType;
}
public void setBigType(ProductBigType bigType) {
this.bigType = bigType;
}
public ProductSmallType getSmallType() {
return smallType;
}
public void setSmallType(ProductSmallType smallType) {
this.smallType = smallType;
}
public int getSpecialPrice() {
return specialPrice;
}
public void setSpecialPrice(int specialPrice) {
this.specialPrice = specialPrice;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
package com.xxx.vo;
import com.xxx.vo.Order;
import com