注册+登录+增删改查+分页查询+jsp+servlet+JavaBean+MySQL+tomcat
此项目为最基本的Java web课程作业,是之前在学校的课程设计。只需要对数据、数据类型进行修改,就可以作为其他名称的项目。
主要技术:Jsp+Servlet+Mysql+Tomcat+Eclipse
适用场合:Java课程设计/Java大作业
项目类型:JAVA WEB项目
用户类型:单用户
开发工具:Eclipse
数据库表:2张
功能介绍:实现注册登录,分页查询,以及对物流信息的增删改查。
1.注册
2.登录
3.分页查询
4.添加物流信息
5.删除物流信息
6.修改物流信息
7.查找物流信息
8.监听器+过滤器
物流信息管理系统
- 1.管理员端功能介绍
-
* 1.1欢迎界面
- 1.2用户注册
- 1.3用户登录
- 1.4物流信息增删改查
- 1.5添加和修改物流信息
- 1.6查询信息
- 2.截取部分代码介绍,可参考风格学习
-
* 2.1addInfo.jsp
- 2.2ExpressBean.java
- 2.3ExpressServlet.java
- 4.数据库设计
1.管理员端功能介绍
1.1欢迎界面
1.2用户注册
1.3用户登录
1.4物流信息增删改查
1.5添加和修改物流信息
1.6查询信息
2.截取部分代码介绍,可参考风格学习
2.1addInfo.jsp
jsp页面内数据通过form表单提交。
<form action="ExpressServlet?method=AddExpressAct" method="post">
<input type="hidden" name="id" />
<div class="form-group">
<label for="expressno">物流订单编号</label>
<div class="form-label-group">
<input type="text" id="eno" name="eno" class="form-control" placeholder="请输入用户名" required="required" autofocus="autofocus">
</div>
</div>
<div class="form-group">
<label for="ename">车辆车牌号</label>
<div class="form-label-group">
<input type="text" id="carno" name="carno" class="form-control" placeholder="请输入车辆车牌号" required="required">
</div>
</div>
<div class="form-group">
<label for="ename">物流物品信息</label>
<div class="form-label-group">
<input type="text" id="goods" name="goods" class="form-control" placeholder="请输入物流拉货物品" required="required">
</div>
</div>
<div class="form-group">
<label for="isStartLocation">始发地</label>
<div class="form-label-group">
<input type="text" id="isStartLocation" name="isStartLocation" class="form-control" placeholder="请输入密码" required="required">
</div>
</div>
<div class="form-group">
<label for="isEndLocation">终点站</label>
<div class="form-label-group">
<input type="text" id="isEndLocation" name="isEndLocation" class="form-control" placeholder="请输入密码" required="required">
</div>
</div><div class="form-group">
<label for="price">物流运费</label>
<div class="form-label-group">
<input type="text" id="price" name="price" class="form-control" placeholder="请输入密码" required="required">
</div>
</div>
<div class="form-group">
<label for="createTime">发货日期</label>
<div class="form-label-group">
<input type="date" id="createTime" name="createTime" class="form-control" placeholder="请输入密码" required="required">
</div>
</div>
<div class="form-group">
<label for="expresser">快递员</label>
<div class="form-label-group">
<input type="text" id="expresser" name="expresser" class="form-control" placeholder="请输入密码" required="required">
</div>
</div>
<input type="submit" class="btn btn-primary btn-block" value="立即添加"></a>
</form>
2.2ExpressBean.java
package bean;
import java.sql.Date;
public class Express {
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getEno() {
return eno;
}
public void setEno(String eno) {
this.eno = eno;
}
public String getCarno() {
return carno;
}
public void setCarno(String carno) {
this.carno = carno;
}
public String getGoods() {
return goods;
}
public void setGoods(String goods) {
this.goods = goods;
}
public String getIsStartLocation() {
return isStartLocation;
}
public void setIsStartLocation(String isStartLocation) {
this.isStartLocation = isStartLocation;
}
public String getIsEndLocation() {
return isEndLocation;
}
public void setIsEndLocation(String isEndLocation) {
this.isEndLocation = isEndLocation;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getExpresser() {
return expresser;
}
public void setExpresser(String expresser) {
this.expresser = expresser;
}
private Integer id;
private String eno;
private String carno;
private String goods;
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
private double price;
private String isStartLocation;
private String isEndLocation;
private Date createTime;
private String expresser;
}
2.3ExpressServlet.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Object attribute= request.getParameter("method");
String method = "";
if(attribute != null){
method = attribute.toString();
}
//显示数据
if("ExpressListAct".equals(method)){
try {
ExpressList(request,response);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return;
}
//删除user操作
if("DelExpressAct".equals(method)){
int id=Integer.parseInt(request.getParameter("id"));
System.out.println(id);
boolean b=dao.deleteExpress(id);
System.out.println(id);
if(b==true) {
try {
ExpressList(request,response);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else {
response.sendRedirect("success.jsp");
}
return;
}
//根据id查询
if("QueryByIdAct".equals(method)){
int id=Integer.parseInt(request.getParameter("id"));
System.out.println(id+"ad");
Express express=dao.queryById(id);
request.setAttribute("list", express);
request.getRequestDispatcher("updateExpress.jsp").forward(request, response);
return;
}
if("findByEnoAct".equals(method)){
String eno=request.getParameter("eno");
System.out.println(eno);
List<Express> list=dao.findByEno(eno);
request.setAttribute("list", list);
request.getRequestDispatcher("listExpress.jsp").forward(request, response);
return;
}
//根据id更改
if("UpdateExpressAct".equals(method)){
int id=Integer.parseInt(request.getParameter("id"));
String eno=request.getParameter("eno");
String carno=request.getParameter("carno");
String goods=request.getParameter("goods");
double price=Double.parseDouble(request.getParameter("price"));
String isStartLocation=request.getParameter("isStartLocation");
String isEndLocation=request.getParameter("isEndLocation");
String expresser=request.getParameter("expresser");
Date createTime=Date.valueOf(request.getParameter("createTime"));
Express record=new Express();
record.setEno(eno);
record.setCarno(carno);
record.setGoods(goods);
record.setPrice(price);
record.setIsStartLocation(isStartLocation);
record.setIsEndLocation(isEndLocation);
record.setCreateTime(createTime);
record.setExpresser(expresser);
boolean b=dao.update(record,id);
if(b==true){
request.setAttribute("message", "");
try {
ExpressList(request, response);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else{
response.sendRedirect("updateExpress.jsp");
}
return;
}
if("AddExpressAct".equals(method)){
String eno=request.getParameter("eno");
String carno=request.getParameter("carno");
String goods=request.getParameter("goods");
double price=Double.parseDouble(request.getParameter("price"));
String isStartLocation=request.getParameter("isStartLocation");
String isEndLocation=request.getParameter("isEndLocation");
String expresser=request.getParameter("expresser");
Date createTime=Date.valueOf(request.getParameter("createTime"));
Express record=new Express();
record.setEno(eno);
record.setCarno(carno);
record.setGoods(goods);
record.setPrice(price);
record.setIsStartLocation(isStartLocation);
record.setIsEndLocation(isEndLocation);
record.setCreateTime(createTime);
record.setExpresser(expresser);
boolean b=dao.insert(record);
if(b==true){
request.setAttribute("message", "");
try {
ExpressList(request, response);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else{
response.sendRedirect("updateExpress.jsp");
}
return;
}
}
4.数据库设计
- ----------------------------
-- Table structure for express
-- ----------------------------
DROP TABLE IF EXISTS `express`;
CREATE TABLE `express` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`eno` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`carno` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`goods` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`isStartLocation` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`isEndLocation` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`createTime` datetime(0) NULL DEFAULT NULL,
`expresser` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`price` double(10, 2) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of express
-- ----------------------------
INSERT INTO `express` VALUES (2, '112211212', '苏A123455', '蔬菜', '江苏南京', '河南南阳', '2020-05-31 00:00:00', '李庆照', 1000.00);
INSERT INTO `express` VALUES (3, '112211212', '苏A123455', '蔬菜', '江苏南京', '河南南阳', '2020-05-31 00:00:00', '李庆照', 1000.00);
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`password` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 14 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES (1, 'admin', '123456');
INSERT INTO `user` VALUES (8, 'test1', '123456');
INSERT INTO `user` VALUES (9, 'test3', '1234567');
INSERT INTO `user` VALUES (11, 'test6', '1234567');
INSERT INTO `user` VALUES (12, 'test4', '123456');
INSERT INTO `user` VALUES (13, 'test4', '123456');
SET FOREIGN_KEY_CHECKS = 1;