可用作javaweb项目、servlet项目、jsp项目的项目设计
物业管理系统
语言:java
技术栈:jsp、bootstrap、jquery、servlet
数据库:MySQL
运行环境
Jdk8 + eclipse或者idea + Tomcat + mysql
本系统分为业主和管理员
符合简单的增删改查
管理员:查看信息,报修管理,公告管理,保安保洁,业主信息,房产信息
业主:查看信息,修改密码,公告查询等
package com.cissst.servlet;
import java.io.IOException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.cissst.entity.Admin;
import com.cissst.service.IAdminService;
import com.cissst.service.impl.AdminServiceImpl;
import com.cissst.util.MD5Util;
public class AdminServlet 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 adminService = new AdminServiceImpl();
if("adminList".equals(action)){
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");
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);
}
}
}
package com.cissst.servlet;
import java.io.IOException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.cissst.entity.Admin;
import com.cissst.entity.CustomAccount;
import com.cissst.service.ICustomAccountService;
import com.cissst.service.impl.CustomAccountServiceImpl;
import com.cissst.util.MD5Util;
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);
RequestDispatcher rd = request.getRequestDispatcher("customAccount/user-custom-list.jsp");
rd.forward(request, response);
}else if("customAccountEdit".equals(action)){
int accountid = Integer.parseInt(request.getParameter("accountid"));
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.setAccountid(accountid);
c.setUsername(username);
c.setPassword(password);
c.setOwnerid(ownerid);
c.setCarid(carid);
ca.update(c);
response.sendRedirect("custom?action=customAccountList");
}else if("customAccountDelete".equals(action)){
String accountid = request.getParameter("accountid");
ca.delete(accountid);
response.sendRedirect("custom?action=customAccountList");
}
else if("change".equals(action)){
String accountid = request.getParameter("accountid");
CustomAccount c = ca.findById(accountid);
request.setAttribute("customAccount", c);
RequestDispatcher rd = request.getRequestDispatcher("customAccount/user-change-passwd.jsp");
rd.forward(request, response);
}else if("customAccountUserEdit".equals(action)){
int accountid = Integer.parseInt(request.getParameter("accountid"));
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.setAccountid(accountid);
c.setUsername(username);
c.setPassword(password);
c.setOwnerid(ownerid);
c.setCarid(carid);
ca.update(c);
response.sendRedirect("custom?action=findById2&accountid="+accountid);
}
}
}
package com.cissst.servlet;
import java.io.IOException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.cissst.entity.Inspection;
import com.cissst.service.IInspectionService;
import com.cissst.service.impl.InspectionServiceImpl;
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);
request.setAttribute("inspection", i);
RequestDispatcher rd = request.getRequestDispatcher("inspection/inspection-edit.jsp");
rd.forward(request, response);
}else if("inspectionEdit".equals(action)){
int id = Integer.parseInt(request.getParameter("id"));
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.setId(id);
i.setPerson(person);
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");
}
}
}
有问题,或者需要协助调试运行项目的也可以