基于javaweb和mysql的ssm+maven小区物业管理系统(JavaWeb JSP MySQL Servlet SSM SpringBoot Layui Ajax)

私信源码获取及调试交流

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

技术框架

JavaBean MVC JSP SSM(Spring SpringMVC MyBatis) Maven MySQL CSS JavaScript Layui Ajax

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

登录、注册、退出、用户模块、公告模块、投诉模块、房产模块、业主模块、车位模块的增删改查管理

eclipse/MyEclipse运行:

idea运行:


@Controller
@RequestMapping
public class HouseController {

    @Autowired
    private HouseService houseService;

    /**
     * 增加房产
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("houseAdd")
    public void add(House vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
        //调用Service层的增加(insert)方法
        houseService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除房产
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("houseDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        houseService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑房产
     * @throws IOException
     */
    @RequestMapping("houseList")
    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword/*keyword != null ? new String(keyword.getBytes("ISO-8859-1"), "UTF-8") : null*/);//查询的关键字
        //User loginUser = (User) request.getSession().getAttribute("loginUser");
        //if (!"管理员".equals(loginUser.getUserType())) {
        //    params.put("createBy", loginUser.getId());
        //}
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(houseService.list(params).get("list")));
    }
}


@Controller
@RequestMapping
public class ParkingController {

    @Autowired
    private ParkingService parkingService;

    /**
     * 增加车位
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("parkingAdd")
    public void add(Parking vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
        //调用Service层的增加(insert)方法
        parkingService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除车位
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("parkingDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        parkingService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑车位
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("parkingEdit")
    public void edit(Parking vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        parkingService.update(vo);
        this.redirectList(request, response);
    }
     * 增加房产
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("houseAdd")
    public void add(House vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
        //调用Service层的增加(insert)方法
        houseService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除房产
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("houseDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        houseService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑房产
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("houseEdit")
    public void edit(House vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        houseService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取房产的详细信息(详情页面与编辑页面要显示该房产的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"houseGet", "houseEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
    @RequestMapping("ownerList")
    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword/*keyword != null ? new String(keyword.getBytes("ISO-8859-1"), "UTF-8") : null*/);//查询的关键字
        //User loginUser = (User) request.getSession().getAttribute("loginUser");
        //if (!"管理员".equals(loginUser.getUserType())) {
        //    params.put("createBy", loginUser.getId());
        //}
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(ownerService.list(params).get("list")));
    }
}

        vo.setPassword(password);
            vo.setCreateBy(0L);
            vo.setUserType("普通用户");
        userService.insert(vo);
        request.getSession().setAttribute("alert_msg", "注册成功!用户名:[" + username + "]");
        request.getRequestDispatcher("login.jsp").forward(request, response);
    }

    @RequestMapping("authLogout")
    public void logout(HttpServletResponse response, HttpServletRequest request) throws IOException {
        HttpSession session = request.getSession();
        User user = (User) session.getAttribute("loginUser");
        if (user != null) {
            session.removeAttribute("loginUser");
        }
        response.sendRedirect("login.jsp");
    }

    @RequestMapping("authValidationCode")
    public void validationCode(HttpServletResponse response, HttpServletRequest request) throws IOException {
        String codeChars = "0123456789";// 图形验证码的字符集合,系统将随机从这个字符串中选择一些字符作为验证码
        //  获得验证码集合的长度
        int charsLength = codeChars.length();
        //  下面三条记录是关闭客户端浏览器的缓冲区
        //  这三条语句都可以关闭浏览器的缓冲区,但是由于浏览器的版本不同,对这三条语句的支持也不同
        //  因此,为了保险起见,建议同时使用这三条语句来关闭浏览器的缓冲区
        response.setHeader("ragma", "No-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0);
        //  设置图形验证码的长和宽(图形的大小)
        int width = 90, height = 20;
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics g = image.getGraphics();//  获得用于输出文字的Graphics对象
        Random random = new Random();
        g.setColor(getRandomColor(180, 250));// 随机设置要填充的颜色
        g.fillRect(0, 0, width, height);//  填充图形背景
        //  设置初始字体
        g.setFont(new Font("Times New Roman", Font.ITALIC, height));
        g.setColor(getRandomColor(120, 180));// 随机设置字体颜色
        //  用于保存最后随机生成的验证码
        StringBuilder validationCode = new StringBuilder();
        //  验证码的随机字体
        String[] fontNames = {"Times New Roman", "Book antiqua", "Arial"};
        for (int i = 0; i < 4; i++) {
            //  随机设置当前验证码的字符的字体
            g.setFont(new Font(fontNames[random.nextInt(3)], Font.ITALIC, height));
            //  随机获得当前验证码的字符
            char codeChar = codeChars.charAt(random.nextInt(charsLength));
            validationCode.append(codeChar);
        //    params.put("createBy", loginUser.getId());
        //}
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(parkingService.list(params).get("list")));
    }
}

@Controller
@RequestMapping
public class HouseController {

    @Autowired
    private HouseService houseService;

    /**
     * 增加房产
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("houseAdd")
    public void add(House vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
        //调用Service层的增加(insert)方法
        houseService.insert(vo);
        this.redirectList(request, response);
    }

public class NoticeController {

    @Autowired
    private NoticeService noticeService;

    /**
     * 增加公告
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("noticeAdd")
    public void add(Notice vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
        //调用Service层的增加(insert)方法
        noticeService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除公告
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("noticeDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        noticeService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑公告
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("noticeEdit")
    public void edit(Notice vo, HttpServletResponse response, HttpServletRequest request) throws IOException {

@Controller
@RequestMapping
public class NoticeController {

    @Autowired
    private NoticeService noticeService;

    /**
     * 增加公告
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("noticeAdd")
    public void add(Notice vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
        //调用Service层的增加(insert)方法
        noticeService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除公告
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("noticeDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        noticeService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑公告
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("noticeEdit")
    public void edit(Notice vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("parkingDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        parkingService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑车位
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("parkingEdit")
    public void edit(Parking vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        parkingService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取车位的详细信息(详情页面与编辑页面要显示该车位的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"parkingGet", "parkingEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        Parking vo = parkingService.get(id);
        request.getSession().setAttribute("vo", vo);
        String to = request.getRequestURI().toLowerCase().contains("get") ? "info" : "edit";//判断是去详情显示页面还是编辑页面
        response.sendRedirect("parking_" + to + ".jsp");
    }

    /**
     * 根据条件查询车位的列表并跳转回页面
     *
     * @param response
     * @param request
     * @param request
     * @throws IOException
     */
    @RequestMapping("noticeAdd")
    public void add(Notice vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
        //调用Service层的增加(insert)方法
        noticeService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除公告
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("noticeDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        noticeService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑公告
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("noticeEdit")
    public void edit(Notice vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        noticeService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取公告的详细信息(详情页面与编辑页面要显示该公告的详情)并跳转回页面

@Controller
@RequestMapping
public class HouseController {

    @Autowired
    private HouseService houseService;

    /**
     * 增加房产
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("houseAdd")
    public void add(House vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
        //调用Service层的增加(insert)方法
        houseService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除房产
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("houseDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
    @RequestMapping("houseList")
    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword/*keyword != null ? new String(keyword.getBytes("ISO-8859-1"), "UTF-8") : null*/);//查询的关键字
        //User loginUser = (User) request.getSession().getAttribute("loginUser");
        //if (!"管理员".equals(loginUser.getUserType())) {
        //    params.put("createBy", loginUser.getId());
        //}
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(houseService.list(params).get("list")));
    }
}

@Controller
@RequestMapping
public class OwnerController {

    @Autowired
    private OwnerService ownerService;

    /**
     * @throws IOException
     */
    @RequestMapping({"complaintGet", "complaintEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        Complaint vo = complaintService.get(id);
        request.getSession().setAttribute("vo", vo);
        String to = request.getRequestURI().toLowerCase().contains("get") ? "info" : "edit";//判断是去详情显示页面还是编辑页面
        response.sendRedirect("complaint_" + to + ".jsp");
    }

    /**
     * 根据条件查询投诉的列表并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("complaintList")
    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword/*keyword != null ? new String(keyword.getBytes("ISO-8859-1"), "UTF-8") : null*/);//查询的关键字
        //User loginUser = (User) request.getSession().getAttribute("loginUser");
        //if (!"管理员".equals(loginUser.getUserType())) {
        //    params.put("createBy", loginUser.getId());
        //}
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(complaintService.list(params).get("list")));
    }
}

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword/*keyword != null ? new String(keyword.getBytes("ISO-8859-1"), "UTF-8") : null*/);//查询的关键字
        //User loginUser = (User) request.getSession().getAttribute("loginUser");
        //if (!"管理员".equals(loginUser.getUserType())) {
        //    params.put("createBy", loginUser.getId());
        //}
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(houseService.list(params).get("list")));
    }
}

@Controller
@RequestMapping
public class OwnerController {

    @Autowired
    private OwnerService ownerService;

    /**
     * 增加业主
     *
     * @param response
     * @param request
    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword/*keyword != null ? new String(keyword.getBytes("ISO-8859-1"), "UTF-8") : null*/);//查询的关键字
        //User loginUser = (User) request.getSession().getAttribute("loginUser");
        //if (!"管理员".equals(loginUser.getUserType())) {
        //    params.put("createBy", loginUser.getId());
        //}
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(houseService.list(params).get("list")));
    }
}

@Controller
@RequestMapping
public class OwnerController {

    @Autowired
    private OwnerService ownerService;

    /**
     * 增加业主
     *
     * @param response
public class ParkingController {

    @Autowired
    private ParkingService parkingService;

    /**
     * 增加车位
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("parkingAdd")
    public void add(Parking vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
        //调用Service层的增加(insert)方法
        parkingService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除车位
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("parkingDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        parkingService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑车位
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("parkingEdit")
    public void edit(Parking vo, HttpServletResponse response, HttpServletRequest request) throws IOException {

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐