一、数据库设计
用户表User
已有的测试数据
二、Java代码编写
Java EE的架构一般分为以下五层:
①.Domain
②.DAO
③.Service
④.Controller
⑤.View
这里的项目结构如下:
使用的环境为:JDK1.8+Servlet3.0+Tomcat8.0
前端统一使用Ajax方式和JSON数据格式向后端发送请求及数据,后端统一返回JSON数据格式的信息
1.Domain层
1 package domain; 2 3 import java.util.Date; 4 5 public class User { 6 7 public User() { 8 9 } 10 11 private Integer id; 12 13 private String account; 14 15 private String password; 16 17 private String name; 18 19 private String info; 20 21 private Date createTime; 22 23 private Date modifiedTime; 24 25 public Integer getId() { 26 return id; 27 } 28 29 public void setId(Integer id) { 30 this.id = id; 31 } 32 33 public String getAccount() { 34 return account; 35 } 36 37 public void setAccount(String account) { 38 this.account = account; 39 } 40 41 public String getPassword() { 42 return password; 43 } 44 45 public void setPassword(String password) { 46 this.password = password; 47 } 48 49 public String getName() { 50 return name; 51 } 52 53 public void setName(String name) { 54 this.name = name; 55 } 56 57 public String getInfo() { 58 return info; 59 } 60 61 public void setInfo(String info) { 62 this.info = info; 63 } 64 65 public Date getCreateTime() { 66 return createTime; 67 } 68 69 public void setCreateTime(Date createTime) { 70 this.createTime = createTime; 71 } 72 73 public Date getModifiedTime() { 74 return modifiedTime; 75 } 76 77 public void setModifiedTime(Date modifiedTime) { 78 this.modifiedTime = modifiedTime; 79 } 80 81 @Override 82 public String toString() { 83 return "User [ 84 + info + ", createTime=" + createTime + ", modifiedTime=" + modifiedTime + "]"; 85 } 86 87 }