基于javaweb+mysql的jsp+servlet智能小区物业管理系统(java+jsp+bootstrap+javascript+servlet+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的JSP+Servlet智能小区物业管理系统(java+jsp+bootstrap+javascript+servlet+mysql)
项目介绍
本项目为后台管理系统,分为管理员与业主两种角色; 管理员主要功能包括: 首页、公告查询、修改密码、报修管理、业主信息、房产信息等;管理员可对业主、房产等信息进行增删改查,业主仅可查看;
业主主要功能包括: 首页、公告查询、修改密码、报修管理、业主信息、房产信息等;
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目:否;
技术栈
- 后端:Servlet 2. 前端:JSP+CSS+JavaScript+jquery+bootstrap
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中database.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入http://localhost:8080/ 登录 管理员账号/密码:admin/123456 业主账号/密码:goodym/123456
public class NoticeServlet extends HttpServlet{
@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
String action=request.getParameter("action");
INoticeService noticeservice=new NoticeServiceImpl();
if("noticelist".equals(action)){
List<Notice> list=new ArrayList<Notice>();
list=noticeservice.FindAll();
request.setAttribute("notice", list);
RequestDispatcher rd=request.getRequestDispatcher("notice/notice-list.jsp");
rd.forward(request,response);
}
else if("noticeadd".equals(action)){
String content=request.getParameter("content");
String ndate=request.getParameter("ndate");
String title=request.getParameter("title");
String uper=request.getParameter("uper");
Notice n=new Notice();
n.setContent(content);
n.setNdate(ndate);
n.setTitle(title);
n.setUper(uper);
noticeservice.Add(n);
response.sendRedirect("notice?action=noticelist");
}
else if("noticedelete".equals(action)){
String id=request.getParameter("id");
noticeservice.Delete(id);
response.sendRedirect("notice?action=noticelist");
}
else if("noticeselect".equals(action)){
String id=request.getParameter("id");
Notice n=noticeservice.Select(id);
request.setAttribute("notice", n);
List<Admin> list = adminService.findAlladmins();
request.setAttribute("admins", list);
RequestDispatcher rd = request.getRequestDispatcher("admin/admin-list.jsp");
rd.forward(request, response);
}else if("adminAdd".equals(action)){
String name = request.getParameter("name");
String password = MD5Util.encode(request.getParameter("password"));
String sex = request.getParameter("sex");
String age = request.getParameter("age");
String tel = request.getParameter("tel");
String phone = request.getParameter("phone");
String addr = request.getParameter("addr");
String memo = request.getParameter("memo");
System.out.println(name+password+tel+phone+addr+memo);
Number ag = Integer.parseInt(age);
Admin a = new Admin();
a.setName(name);
a.setPassword(password);
a.setSex(sex);
a.setAge(ag);
a.setTel(tel);
a.setPhone(phone);
a.setAddr(addr);
a.setMemo(memo);
adminService.save(a);
response.sendRedirect("admin?action=adminList");
}else if("findById".equals(action)){
String id = request.getParameter("id");
Admin a = adminService.findById(id);
request.setAttribute("admin", a);
RequestDispatcher rd = request.getRequestDispatcher("admin/admin-edit.jsp");
rd.forward(request, response);
}else if("adminEdit".equals(action)){
int id = Integer.parseInt(request.getParameter("id"));
String name = request.getParameter("name");
h.setFloor(floor);
h.setDirection(direction);
h.setMemo(memo);
h.setOwnerid(ownerid);
ihs.update(h);
response.sendRedirect("house?action=houseList");
}else if("houseDelete".equals(action)){
String id = request.getParameter("id");
ihs.delete(id);
response.sendRedirect("house?action=houseList");
}else if("findById".equals(action)){
String id = request.getParameter("id");
House h = ihs.findById(id);
request.setAttribute("house",h);
RequestDispatcher rd = request.getRequestDispatcher("house/house-edit.jsp");
rd.forward(request, response);
}
}
}
c.setAccountid(accountid);
c.setUsername(username);
c.setPassword(password);
c.setOwnerid(ownerid);
c.setCarid(carid);
ca.update(c);
response.sendRedirect("custom?action=findById2&accountid="+accountid);
}
}
}
public class HouseServlet extends HttpServlet{
@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
String action = request.getParameter("action");
IHouseService ihs = new HouseServiceImpl();
if("houseList".equals(action)){
List<House> list = ihs.findAllHouse();
request.setAttribute("houses", list);
RequestDispatcher rd = request.getRequestDispatcher("house/house-list.jsp");
rd.forward(request, response);
request.setAttribute("admin", a);
RequestDispatcher rd = request.getRequestDispatcher("admin/admin-edit.jsp");
rd.forward(request, response);
}else if("adminEdit".equals(action)){
int id = Integer.parseInt(request.getParameter("id"));
String name = request.getParameter("name");
String password = MD5Util.encode(request.getParameter("password"));
String sex = request.getParameter("sex");
String age = request.getParameter("age");
String tel = request.getParameter("tel");
String phone = request.getParameter("phone");
String addr = request.getParameter("addr");
String memo = request.getParameter("memo");
int ag = Integer.parseInt(age);
Admin a = new Admin();
a.setId(id);
a.setName(name);
a.setPassword(password);
a.setSex(sex);
a.setAge(ag);
a.setTel(tel);
a.setPhone(phone);
a.setAddr(addr);
a.setMemo(memo);
adminService.update(a);
response.sendRedirect("admin?action=adminList");
}else if("adminDelete".equals(action)){
String id = request.getParameter("id");
adminService.delete(id);
response.sendRedirect("admin?action=adminList");
}
else if("change".equals(action)){
String id = request.getParameter("id");
Admin a = adminService.findById(id);
request.setAttribute("admin", a);
RequestDispatcher rd = request.getRequestDispatcher("admin/adminChange.jsp");
rd.forward(request, response);
}
}
}
String rdate = request.getParameter("rdate");
String tcost = request.getParameter("tcost");
String scost = request.getParameter("scost");
String maintainer = request.getParameter("maintainer");
String smemo = request.getParameter("smemo");
Double tt,st;
if(tcost==null){tt=(double)0.0;}else{tt = Double.parseDouble(tcost);}
if(scost==null||scost.equals("")){st=(double)0.0;}else{ st = Double.parseDouble(scost);}
Maintain m = new Maintain();
m.setThing(thing);
m.setStatus(status);
m.setHomesnumber(homesnumber);
m.setSdate(sdate);
m.setRdate(rdate);
m.setTcost(tt);
m.setScost(st);
m.setMaintainer(maintainer);
m.setSmemo(smemo);
maintainService.save(m);
response.sendRedirect("main?action=maintainList");
return;
}else if("findById".equals(action)){
String id = request.getParameter("id");
Maintain a = maintainService.findById(id);
request.setAttribute("maintain", a);
RequestDispatcher rd = request.getRequestDispatcher("maintain/maintain-edit.jsp");
rd.forward(request, response);
}else if("maintainUpdate".equals(action)){
int id = Integer.parseInt(request.getParameter("id"));
String thing = request.getParameter("thing");
String status = request.getParameter("status");
String homesnumber = request.getParameter("homesnumber");
String sdate = request.getParameter("sdate");
String rdate = request.getParameter("rdate");
String tcost = request.getParameter("tcost");
String scost = request.getParameter("scost");
String maintainer = request.getParameter("maintainer");
String smemo = request.getParameter("smemo");
Double tt,st;
if(tcost==null){tt=(double)0.0;}else{tt = Double.parseDouble(tcost);}
if(scost==null||scost.equals("")){st=(double)0.0;}else{st = Double.parseDouble(scost);}
Double tt,st;
if(tcost==null){tt=(double)0.0;}else{tt = Double.parseDouble(tcost);}
if(scost==null||scost.equals("")){st=(double)0.0;}else{ st = Double.parseDouble(scost);}
Maintain m = new Maintain();
m.setThing(thing);
m.setStatus(status);
m.setHomesnumber(homesnumber);
m.setSdate(sdate);
m.setRdate(rdate);
m.setTcost(tt);
m.setScost(st);
m.setMaintainer(maintainer);
m.setSmemo(smemo);
maintainService.save(m);
response.sendRedirect("main?action=maintainUserList&username="+maintainer);
}else if("maintainUserDelete".equals(action)){
String maintainer = request.getParameter("maintainer");
String id = request.getParameter("id");
maintainService.delete(id);
response.sendRedirect("main?action=maintainUserList&username="+maintainer);
}
}
}
public class CustomAccountServlet extends HttpServlet{
@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
response.setContentType("text/html;charset=utf-8");
String action=request.getParameter("action");
INoticeService noticeservice=new NoticeServiceImpl();
if("noticelist".equals(action)){
List<Notice> list=new ArrayList<Notice>();
list=noticeservice.FindAll();
request.setAttribute("notice", list);
RequestDispatcher rd=request.getRequestDispatcher("notice/notice-list.jsp");
rd.forward(request,response);
}
else if("noticeadd".equals(action)){
String content=request.getParameter("content");
String ndate=request.getParameter("ndate");
String title=request.getParameter("title");
String uper=request.getParameter("uper");
Notice n=new Notice();
n.setContent(content);
n.setNdate(ndate);
n.setTitle(title);
n.setUper(uper);
noticeservice.Add(n);
response.sendRedirect("notice?action=noticelist");
}
else if("noticedelete".equals(action)){
String id=request.getParameter("id");
noticeservice.Delete(id);
response.sendRedirect("notice?action=noticelist");
}
else if("noticeselect".equals(action)){
String id=request.getParameter("id");
Notice n=noticeservice.Select(id);
request.setAttribute("notice", n);
RequestDispatcher rd = request.getRequestDispatcher("notice/notice-edit.jsp");
rd.forward(request, response);
}
else if("noticeedit".equals(action)){
String content=request.getParameter("content");
String ndate=request.getParameter("ndate");
String title=request.getParameter("title");
String uper=request.getParameter("uper");
int id= Integer.parseInt(request.getParameter("id"));
String tcost = request.getParameter("tcost");
String scost = request.getParameter("scost");
String maintainer = request.getParameter("maintainer");
String smemo = request.getParameter("smemo");
Double tt,st;
if(tcost==null){tt=(double)0.0;}else{tt = Double.parseDouble(tcost);}
if(scost==null||scost.equals("")){st=(double)0.0;}else{ st = Double.parseDouble(scost);}
Maintain m = new Maintain();
m.setThing(thing);
m.setStatus(status);
m.setHomesnumber(homesnumber);
m.setSdate(sdate);
m.setRdate(rdate);
m.setTcost(tt);
m.setScost(st);
m.setMaintainer(maintainer);
m.setSmemo(smemo);
maintainService.save(m);
response.sendRedirect("main?action=maintainList");
return;
}else if("findById".equals(action)){
String id = request.getParameter("id");
Maintain a = maintainService.findById(id);
request.setAttribute("maintain", a);
RequestDispatcher rd = request.getRequestDispatcher("maintain/maintain-edit.jsp");
rd.forward(request, response);
}else if("maintainUpdate".equals(action)){
int id = Integer.parseInt(request.getParameter("id"));
String thing = request.getParameter("thing");
String status = request.getParameter("status");
String homesnumber = request.getParameter("homesnumber");
String sdate = request.getParameter("sdate");
String rdate = request.getParameter("rdate");
String tcost = request.getParameter("tcost");
String scost = request.getParameter("scost");
String maintainer = request.getParameter("maintainer");
String smemo = request.getParameter("smemo");
Double tt,st;
if(tcost==null){tt=(double)0.0;}else{tt = Double.parseDouble(tcost);}
i.setType(type);
i.setItime(itime);
i.setConductor(conductor);
i.setParty(party);
i.setResult(result);
i.setMemo(memo);
iis.update(i);
response.sendRedirect("inspection?action=inspectionList");
}else if("inspectionDelete".equals(action)){
String id = request.getParameter("id");
iis.delete(id);
response.sendRedirect("inspection?action=inspectionList");
}
}
}
public class UserServlet extends HttpServlet{
@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
String action = request.getParameter("action");
IAdminService as = new AdminServiceImpl();
ICustomAccountService cs = new CustomAccountServiceImpl();
HttpSession session = request.getSession();
i.setConductor(conductor);
i.setParty(party);
i.setResult(result);
i.setMemo(memo);
iis.update(i);
response.sendRedirect("inspection?action=inspectionList");
}else if("inspectionDelete".equals(action)){
String id = request.getParameter("id");
iis.delete(id);
response.sendRedirect("inspection?action=inspectionList");
}
}
}
public class UserServlet extends HttpServlet{
@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
String action = request.getParameter("action");
if(tcost==null){tt=(double)0.0;}else{tt = Double.parseDouble(tcost);}
if(scost==null||scost.equals("")){st=(double)0.0;}else{ st = Double.parseDouble(scost);}
Maintain m = new Maintain();
m.setThing(thing);
m.setStatus(status);
m.setHomesnumber(homesnumber);
m.setSdate(sdate);
m.setRdate(rdate);
m.setTcost(tt);
m.setScost(st);
m.setMaintainer(maintainer);
m.setSmemo(smemo);
maintainService.save(m);
response.sendRedirect("main?action=maintainUserList&username="+maintainer);
}else if("maintainUserDelete".equals(action)){
String maintainer = request.getParameter("maintainer");
String id = request.getParameter("id");
maintainService.delete(id);
response.sendRedirect("main?action=maintainUserList&username="+maintainer);
}
}
}
public class CustomAccountServlet extends HttpServlet{
@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
public class MaintainServlet extends HttpServlet {
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=UTF-8;");
String action = request.getParameter("action");
IMaintainService maintainService = new MaintainServiceImpl();
ICustomAccountService ca = new CustomAccountServiceImpl();
if("maintainList".equals(action)){
List<Maintain> list = maintainService.findAllMaintains();
request.setAttribute("maintains", list);
RequestDispatcher rd = request.getRequestDispatcher("maintain/maintain-list.jsp");
rd.forward(request, response);
}
else if("maintainAdd".equals(action)){
String thing = request.getParameter("thing");
String status = request.getParameter("status");
String homesnumber = request.getParameter("homesnumber");
String sdate = request.getParameter("sdate");
String rdate = request.getParameter("rdate");
String tcost = request.getParameter("tcost");
String scost = request.getParameter("scost");
String maintainer = request.getParameter("maintainer");
String smemo = request.getParameter("smemo");
Double tt,st;
if(tcost==null){tt=(double)0.0;}else{tt = Double.parseDouble(tcost);}
if(scost==null||scost.equals("")){st=(double)0.0;}else{ st = Double.parseDouble(scost);}
Maintain m = new Maintain();
m.setThing(thing);
m.setStatus(status);
m.setHomesnumber(homesnumber);
m.setSdate(sdate);
m.setRdate(rdate);
m.setTcost(tt);
m.setScost(st);
m.setMaintainer(maintainer);
m.setSmemo(smemo);
}else if("findById".equals(action)){
String id = request.getParameter("id");
Maintain a = maintainService.findById(id);
request.setAttribute("maintain", a);
RequestDispatcher rd = request.getRequestDispatcher("maintain/maintain-edit.jsp");
rd.forward(request, response);
}else if("maintainUpdate".equals(action)){
int id = Integer.parseInt(request.getParameter("id"));
String thing = request.getParameter("thing");
String status = request.getParameter("status");
String homesnumber = request.getParameter("homesnumber");
String sdate = request.getParameter("sdate");
String rdate = request.getParameter("rdate");
String tcost = request.getParameter("tcost");
String scost = request.getParameter("scost");
String maintainer = request.getParameter("maintainer");
String smemo = request.getParameter("smemo");
Double tt,st;
if(tcost==null){tt=(double)0.0;}else{tt = Double.parseDouble(tcost);}
if(scost==null||scost.equals("")){st=(double)0.0;}else{st = Double.parseDouble(scost);}
Maintain m = new Maintain();
m.setId(id);
m.setThing(thing);
m.setStatus(status);
m.setHomesnumber(homesnumber);
m.setSdate(sdate);
m.setRdate(rdate);
m.setTcost(tt);
m.setScost(st);
m.setMaintainer(maintainer);
m.setSmemo(smemo);
maintainService.update(m);
response.sendRedirect("main?action=maintainList");
}else if("maintainDelete".equals(action)){
String thing = request.getParameter("thing");
String status = request.getParameter("status");
String homesnumber = request.getParameter("homesnumber");
String sdate = request.getParameter("sdate");
String rdate = request.getParameter("rdate");
String tcost = request.getParameter("tcost");
String scost = request.getParameter("scost");
String maintainer = request.getParameter("maintainer");
String smemo = request.getParameter("smemo");
Double tt,st;
if(tcost==null){tt=(double)0.0;}else{tt = Double.parseDouble(tcost);}
if(scost==null||scost.equals("")){st=(double)0.0;}else{ st = Double.parseDouble(scost);}
Maintain m = new Maintain();
m.setThing(thing);
m.setStatus(status);
m.setHomesnumber(homesnumber);
m.setSdate(sdate);
m.setRdate(rdate);
m.setTcost(tt);
m.setScost(st);
m.setMaintainer(maintainer);
m.setSmemo(smemo);
maintainService.save(m);
response.sendRedirect("main?action=maintainList");
return;
}else if("findById".equals(action)){
String id = request.getParameter("id");
Maintain a = maintainService.findById(id);
request.setAttribute("maintain", a);
RequestDispatcher rd = request.getRequestDispatcher("maintain/maintain-edit.jsp");
rd.forward(request, response);
}else if("maintainUpdate".equals(action)){
int id = Integer.parseInt(request.getParameter("id"));
String thing = request.getParameter("thing");
}else if("adminAdd".equals(action)){
String name = request.getParameter("name");
String password = MD5Util.encode(request.getParameter("password"));
String sex = request.getParameter("sex");
String age = request.getParameter("age");
String tel = request.getParameter("tel");
String phone = request.getParameter("phone");
String addr = request.getParameter("addr");
String memo = request.getParameter("memo");
System.out.println(name+password+tel+phone+addr+memo);
Number ag = Integer.parseInt(age);
Admin a = new Admin();
a.setName(name);
a.setPassword(password);
a.setSex(sex);
a.setAge(ag);
a.setTel(tel);
a.setPhone(phone);
a.setAddr(addr);
a.setMemo(memo);
adminService.save(a);
response.sendRedirect("admin?action=adminList");
}else if("findById".equals(action)){
String id = request.getParameter("id");
Admin a = adminService.findById(id);
request.setAttribute("admin", a);
RequestDispatcher rd = request.getRequestDispatcher("admin/admin-edit.jsp");
rd.forward(request, response);
}else if("adminEdit".equals(action)){
int id = Integer.parseInt(request.getParameter("id"));
String name = request.getParameter("name");
String password = MD5Util.encode(request.getParameter("password"));
String sex = request.getParameter("sex");
String age = request.getParameter("age");
String tel = request.getParameter("tel");
String phone = request.getParameter("phone");
String addr = request.getParameter("addr");
String memo = request.getParameter("memo");
public class InspectionServlet extends HttpServlet{
@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
String action = request.getParameter("action");
IInspectionService iis = new InspectionServiceImpl();
if("inspectionList".equals(action)){
List<Inspection> list = iis.findAllinspections();
request.setAttribute("inspections", list);
RequestDispatcher rd = request.getRequestDispatcher("inspection/inspection-list.jsp");
rd.forward(request, response);
}else if("inspectionAdd".equals(action)){
String person = request.getParameter("person");
String type = request.getParameter("type");
String itime = request.getParameter("itime");
String conductor = request.getParameter("conductor");
String party = request.getParameter("party");
String result = request.getParameter("result");
String memo = request.getParameter("memo");
Inspection i = new Inspection();
i.setPerson(person);
i.setType(type);
i.setItime(itime);
i.setConductor(conductor);
i.setParty(party);
i.setResult(result);
i.setMemo(memo);
iis.save(i);
response.sendRedirect("inspection?action=inspectionList");
}else if("findById".equals(action)){
String id = request.getParameter("id");
Inspection i = iis.findById(id);
public class CustomAccountServlet extends HttpServlet{
@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
String action = request.getParameter("action");
ICustomAccountService ca = new CustomAccountServiceImpl();
if("customAccountList".equals(action)){
List<CustomAccount> list = ca.findAllcustomAccount();
request.setAttribute("customAccounts", list);
RequestDispatcher rd = request.getRequestDispatcher("customAccount/custom-list.jsp");
rd.forward(request,response);
}else if("customAccountAdd".equals(action)){
String username = request.getParameter("username");
String password = MD5Util.encode(request.getParameter("password"));
String ownerid = request.getParameter("ownerid");
String carid = request.getParameter("carid");
CustomAccount c = new CustomAccount();
c.setUsername(username);
c.setPassword(password);
c.setOwnerid(ownerid);
c.setCarid(carid);
ca.save(c);
response.sendRedirect("custom?action=customAccountList");
}else if("findById".equals(action)){
String accountid = request.getParameter("accountid");
CustomAccount c = ca.findById(accountid);
request.setAttribute("customAccount", c);
RequestDispatcher rd = request.getRequestDispatcher("customAccount/custom-edit.jsp");
rd.forward(request, response);
}else if("findById2".equals(action)){
String accountid = request.getParameter("accountid");
CustomAccount c = ca.findById(accountid);
request.setAttribute("customAccount", c);