SSM框架整合项目 :租房管理系统

Posted 谁将新樽辞旧月,今月曾经照古人

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SSM框架整合项目 :租房管理系统相关的知识,希望对你有一定的参考价值。

 使用ssm框架整合,oracle数据库

框架:

Spring

SpringMVC

MyBatis

导包:

1, spring

2, MyBatis

3, mybatis-spring

4, fastjson

5, aspectweaver----AspectJ框架

6, log4j-----打印日志信息

7, ojdbc6.jar

8, jstl.jar, standard.jar----标准标签库

9, commons-logging-1.2.jar

10,……

项目结构:

配置文件同前面:http://www.cnblogs.com/jiangwz/p/7674275.html

项目代码:

model:

 1 package com.hanqi.model;
 2 
 3 public class House {
 4     
 5     private Integer id;
 6     private String keyword;
 7     private String area;
 8     private Integer squaremeter;
 9     private Integer rent;
10     private String renttype;
11     private String housetype;
12 
13     public House(Integer id, String keyword, String area, Integer squaremeter, Integer rent, String renttype,
14             String housetype) {
15         super();
16         this.id = id;
17         this.keyword = keyword;
18         this.area = area;
19         this.squaremeter = squaremeter;
20         this.rent = rent;
21         this.renttype = renttype;
22         this.housetype = housetype;
23     }
24 
25     public House() {
26         super();
27         // TODO Auto-generated constructor stub
28     }
29 
30     public Integer getId() {
31         return id;
32     }
33 
34     public void setId(Integer id) {
35         this.id = id;
36     }
37 
38     public String getKeyword() {
39         return keyword;
40     }
41 
42     public void setKeyword(String keyword) {
43         this.keyword = keyword;
44     }
45 
46     public String getArea() {
47         return area;
48     }
49 
50     public void setArea(String area) {
51         this.area = area;
52     }
53 
54     public Integer getSquaremeter() {
55         return squaremeter;
56     }
57 
58     public void setSquaremeter(Integer squaremeter) {
59         this.squaremeter = squaremeter;
60     }
61 
62     public Integer getRent() {
63         return rent;
64     }
65 
66     public void setRent(Integer rent) {
67         this.rent = rent;
68     }
69 
70     public String getRenttype() {
71         return renttype;
72     }
73 
74     public void setRenttype(String renttype) {
75         this.renttype = renttype;
76     }
77 
78     public String getHousetype() {
79         return housetype;
80     }
81 
82     public void setHousetype(String housetype) {
83         this.housetype = housetype;
84     }
85 
86     @Override
87     public String toString() {
88         return "House [id=" + id + ", keyword=" + keyword + ", area=" + area + ", SQUAREMETER=" + squaremeter
89                 + ", rent=" + rent + ", renttype=" + renttype + ", housetype=" + housetype + "]";
90     }
91 
92 }

dao层:

 1 package com.hanqi.dao;
 2 
 3 import java.util.List;
 4 
 5 import com.hanqi.model.House;
 6 
 7 public interface HouseDao {
 8 
 9     List<House> selectAll();
10     
11     int inserthouse(House house);
12 
13     int delhouse(Integer id);
14 
15     int updatehouse(House house);
16 
17     List<House> selectinfo(House house);
18 
19 }

dao层实现方法:

 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <!DOCTYPE mapper
 3   PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 4   "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 5 <mapper namespace="com.hanqi.dao.HouseDao">
 6 
 7     <select id="selectAll" resultType="House">
 8         select t.*from TABLE_HOUSE t
 9     </select>
10     
11     <insert id="inserthouse" parameterType="House" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
12         insert into TABLE_HOUSE values(test1.nextval,#{keyword},#{area},#{squaremeter},#{rent},#{renttype},#{housetype})
13     </insert>
14     
15     <delete id="delhouse" parameterType="Map">
16         delete TABLE_HOUSE t where t.id=#{id}
17     </delete>
18     
19     <update id="updatehouse" parameterType="Map">
20         update TABLE_HOUSE t set t.keyword=#{keyword},t.area=#{area},t.squaremeter=#{squaremeter},t.rent=#{rent},t.renttype=#{renttype},t.housetype=#{housetype} where t.id=#{id}
21     </update>
22     
23     <select id="selectinfo" resultType="House" parameterType="House">
24         select t.* from TABLE_HOUSE t
25         <where>
26             <if test="keyword!=null">
27                 and t.keyword like #{keyword}
28             </if>
29             <if test="area!=null">
30                 and t.area=#{area}
31             </if>
32             <if test="renttype!=null">
33                 and t.renttype in #{renttype}
34             </if>
35             <if test="housetype!=null">
36                 and t.housetype=#{housetype}
37             </if>
38         </where>
39         
40     </select>
41 </mapper>

controller控制器:

 1 package com.hanqi.controller;
 2 
 3 import java.util.ArrayList;
 4 import java.util.List;
 5 
 6 import org.springframework.beans.factory.annotation.Autowired;
 7 import org.springframework.stereotype.Controller;
 8 import org.springframework.ui.Model;
 9 import org.springframework.web.bind.annotation.RequestMapping;
10 import org.springframework.web.bind.annotation.ResponseBody;
11 import org.springframework.web.bind.annotation.SessionAttributes;
12 import org.springframework.web.servlet.ModelAndView;
13 
14 import com.alibaba.fastjson.JSONObject;
15 import com.hanqi.dao.HouseDao;
16 import com.hanqi.model.House;
17 
18 @Controller
19 @SessionAttributes("currentUser")
20 @RequestMapping("/house")
21 public class HouseController {
22 
23     @Autowired
24     private HouseDao houseDao;
25     
26     @ResponseBody
27     @RequestMapping("/selectAll")
28     public JSONObject selectAll() {
29         JSONObject jo = new JSONObject();
30         List<House> list = houseDao.selectAll();
31         jo.put("total", list.size());
32         jo.put("rows", list);
33         
34         return jo;
35     }
36     
37     @ResponseBody
38     @RequestMapping("/selectinfo")
39     public ModelAndView  selectinfo(House house){
40         
41         house.setKeyword("%"+house.getKeyword()+"%");
42         List<House> list = houseDao.selectinfo(house);
43         ModelAndView modelAndView = new ModelAndView();
44         modelAndView.setViewName("houselook3");
45         modelAndView.addObject("list",list);
46 
47         return modelAndView;
48         
49     }
50     
51     @ResponseBody
52     @RequestMapping("/selectAll1")
53     public ModelAndView selectAll1(Model model) {
54         //List<House> list = houseDao.selectAll();
55         //System.out.println(list);
56         
57         //model.addAttribute("list", list);
58 
59         ModelAndView mv = new ModelAndView("redirect:/houselook.jsp");
60         return mv;
61         
62     }
63 
64     @RequestMapping("/selectAll2")
65     public String selectAll2(Model model) {
66         List<House> list = houseDao.selectAll();
67         System.out.println(list);
68         model.addAttribute("list", list);
69 
70         return "houselook2";
71     }
72     
73     @ResponseBody
74     @RequestMapping("/addhouse")
75     public ModelAndView addhouse(House house) {
76         int i=houseDao.inserthouse(house);
77         
78         ModelAndView mv = new ModelAndView("redirect:/index.jsp");
79         return mv;
80         
81     }
82     
83     @ResponseBody
84     @RequestMapping("/delhouse")
85     public ModelAndView delhouse(Integer id) {
86         int i=houseDao.delhouse(id);
87         ModelAndView mv = new ModelAndView("redirect:/index.jsp");
88         return mv;
89     }
90     
91     @ResponseBody
92     @RequestMapping("/updatehouse")
93     public ModelAndView updatehouse(House house) {
94         int i=houseDao.updatehouse(house);
95         ModelAndView mv = new ModelAndView("redirect:/index.jsp");
96         return mv;
97     }
98     
99 }

前台:

  1 <%@ page language="java" contentType="text/html; charset=UTF-8"
  2     pageEncoding="UTF-8"
  3     %>
  4 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  5 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  6 <html>
  7 <head>
  8 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  9 <script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
 10 <script type="text/javascript"
 11     src="jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
 12     <link rel="shortcut icon" href="img/logo1.jpg"/>
 13 <link type="text/css" rel="stylesheet"
 14     href="jquery-easyui-1.5.1/themes/icon.css"></link>
 15 <link type="text/css" rel="stylesheet"
 16     href="jquery-easyui-1.5.1/themes/default/easyui.css"></link>
 17 <script type="text/javascript"
 18     src="jquery-easyui-1.5.1/locale/easyui-lang-zh_CN.js"></script>
 19 <title>租房管理</title>
 20 <%
 21     String basePath = request.getContextPath();
 22 %>
 23 <!-- <script type="text/javascript" src="js/index.js"></script> -->
 24 <style type="text/css">
 25 .datagrid-btable tr {
 26     height: 30px;
 27 }
 28 </style>
 29 </head>
 30 
 31 <body class="easyui-layout">
 32     <!-- 添加商品 -->
 33     <div data-options="region:\'north\',split:true"
 34         style="height: 50px; background-color: cornflowerblue">
 35         
 36     </div>
 37     <!-- 对话框开始 -->
 38     <div data-options="region:\'center\',split:true"
 39         style="padding: 5px; background: #eee">
 40         <div id="tabs" class="easyui-tabs" style="width: 100%; height: 100%;">
 41             <div title="主页" style="">
 42                 <table id="table"></table>
 43                 <!-- 添加的表单 -->
 44                 <div id="zhong" style="display: none">
 45                     <form id="addhouse" method="post"
 46                         style="width: 600px; padding: 20px">
 47                         关键字:<input type="text" name="keyword"><br>
 48                         地区:<input type="text" name="area"><br>
 49                         面积:<input type="text" name="squaremeter"><br>
 50                         租金:<input type="text" name="rent"><br>
 51                         租赁方式:<input type="text" name="renttype"><br>
 52                         房屋类型:<input type="text" name="housetype"><br>
 53                         <input type="submit" name="" id="" value="提交" /><br>
 54                         <input type="reset" value="重置"><br>
 55                     </form>
 56                 </div>
 57                 <!-- 修改的表单 -->
 58                 <div id="gai" style="display: none">
 59                     <form id="gaihouse" action="house/updatehouse.do" method="post"
 60                         style="width: 600px; padding: 20px">
 61                         id:<input type="text" name="id"><br>
 62                         关键字:<input type="text" name="keyword"><br>
 63                         地区:<input type="text" name="area"><br>
 64                         面积:<input type="text" name="squaremeter"><br>
 65                         租金:<input type="text" name="rent"><br>
 66                         租赁方式:<input type="text" name="renttype"><br>
 67                         房屋类型:<input type="text" name="housetype"><br>
 68                         <input type="submit" name="" id="" value基于SSM实现在线租房系统

分布式电商项目(02)--后台管理系统SSM框架整合

SSM框架整合项目 :投票系统

SSM 框架 ---项目整合

IDEA+SSM+Maven实现商品管理系统(超详细SSM整合项目)

SSM 项目整合详细解读