在“易居住房1”的基础上进行增加或修改代码
“IHouseViewDao.java”增加代码
HouseView findHouseByHouseId(int houseId);
List<HouseView> findHouseByType(int houseType);
“IHouseViewService.java”增加代码
HouseView findHouseByHouseId(int houseId);
List<HouseView> findHouseByType(int currentPage,int houseType);
“HouseViewService.java”增加代码
@Override
public HouseView findHouseByHouseId(int houseId) {
return houseViewDao.findHouseByHouseId(houseId);
}
@Override
public List<HouseView> findHouseByType(int currentPage,int houseType) {
PageHelper.startPage(currentPage,5);
return houseViewDao.findHouseByType(houseType);
}
“HouseViewController.java”增加代码
@RequestMapping("findHouseById.do")
public ModelAndView findHouseByHouseId(int houseId){
HouseView house=houseViewService.findHouseByHouseId(houseId);
ModelAndView mv=new ModelAndView();
mv.addObject("houseInfo",house);
mv.setViewName("details");
return mv;
}
@RequestMapping("findHouse.do")
public ModelAndView findHouse(int currentPage,int houseType){
ModelAndView mv=new ModelAndView();
List<HouseView> houses=houseViewService.findHouseByType(currentPage,houseType);
List<HouseView> fh=houseViewService.findFourHouseByType(houseType);
PageInfo<HouseView> pageInfo=new PageInfo<>(houses);
mv.addObject("pageInfo",pageInfo);
mv.addObject("fh",fh);
if (houseType==0){
mv.setViewName("newhouse");
}else if (houseType==1){
mv.setViewName("oldhouse");
}else {
mv.setViewName("renthouse");
}
return mv;
}
“HouseMapper.xml”增加代码
<select id="findHouseByHouseId" parameterType="int" resultType="com.yiju.pojo.HouseView">
select * from tb_house a,tb_house_info b where a.house_id=b.house_id and a.is_delete=0
and a.house_id=#{houseId}
</select>
<select id="findHouseByType" parameterType="int" resultType="com.yiju.pojo.HouseView">
select * from tb_house a,tb_house_info b where a.house_id=b.house_id and a.is_delete=0
and a.house_type=#{houseType}
</select>
“main.jsp”修改“主页推荐栏”中的“更多”,房子图片、文字的链接,修改代码如下
<%--展示主页推荐栏--%>
<div class="content">
<div class="width1190">
<%--【新房推荐】--%>
<%--FIXME 这里添加跳转事件--%>
<h2 class="title"><a style="color:#F1323B">❤</a>新房推荐<a href="${pageContext.request.contextPath}/house/findHouse.do?houseType=0¤tPage=0">更多>></a></h2>
<div class="index-fang-list">
<%--FIXME 这里使用Foreach循环,从数据库读取房屋信息 --%>
<c:forEach items="${newHouses}" var="nh">
<dl>
<dt>
<a href="${pageContext.request.contextPath}/house/findHouseById.do?houseId=${nh.houseId}">
<img src="http://image.cxhit.com/${nh.houseHeadimg}" width="286" height="188"/>
</a>
</dt>
<dd>
<h3>
<a href="${pageContext.request.contextPath}/house/findHouseById.do?houseId=${nh.houseId}">
${nh.houseTitle}</a>
</h3>
<div class="hui">${nh.houseLayout} | ${nh.houseArea} | ${nh.houseDecorate}</div>
</dd>
</dl>
</c:forEach>
<div class="clears"></div>
</div><!--index-fang-list/-->
<%----%>
<%--二手房推荐--%>
<h2 class="title"><a style="color:#F1323B">❤</a>二手房推荐 <a href="${pageContext.request.contextPath}/house/findHouse.do?houseType=1¤tPage=0">更多>></a></h2>
<div class="index-fang-list">
<c:forEach items="${oldHouses}" var="oh">
<dl>
<dt>
<a href="${pageContext.request.contextPath}/house/findHouseById.do?houseId=${oh.houseId}">
<img src="http://image.cxhit.com/${oh.houseHeadimg}" width="286" height="188"/>
</a>
</dt>
<dd>
<h3>
<a href="${pageContext.request.contextPath}/house/findHouseById.do?houseId=${oh.houseId}">
${oh.houseTitle}</a>
</h3>
<div class="hui">${oh.houseLayout} | ${oh.houseArea} | ${oh.houseDecorate}</div>
</dd>
</dl>
</c:forEach>
<div class="clears"></div>
</div><!--index-fang-list/-->
<%--【租房推荐】--%>
<h2 class="title"><a style="color:#F1323B">❤</a>租房推荐 <a href="${pageContext.request.contextPath}/house/findHouse.do?houseType=2¤tPage=0">更多>></a></h2>
<div class="index-ershou">
<%--左侧栏--%>
<div class="in-er-left">
<a href="#"><img src="images/fangt1.jpg" width="380" height="285"/></a>
<div class="in-er-left-text">
<strong class="fl">闵行南方发的撒的发的司法</strong>
<strong class="fr alignRight">¥2841</strong>
</div>
</div><!--in-er-left/-->
<%--右侧栏--%>
<div class="in-er-right">
<c:forEach items="${rentHouses}" var="rh">
<dl>
<dt>
<a href="${pageContext.request.contextPath}/house/findHouseById.do?houseId=${rh.houseId}">
<img src="http://image.cxhit.com/${rh.houseHeadimg}" style="width: 150px; height: 115px;" width="150" height="115"/>
</a>
</dt>
<dd>
<h3>
<a href="${pageContext.request.contextPath}/house/findHouseById.do?houseId=${rh.houseId}">
${rh.houseTitle}</a>
</h3>
<br>
<div class="in-er-right-text">
${rh.houseAddress}
</div>
<div class="price">¥<strong>¥${rh.housePrice}${rh.priceUnit}</strong></div>
</dd>
<div class="clears"></div>
</dl>
</c:forEach>
<div class="clears"></div>
</div><!--in-er-right/-->
<div class="clears"></div>
</div><!--index-ershou/-->
<%--【二手房推荐END】--%>
</div><!--width1190/-->
</div><!--content/-->
“page”包代码如下
“basefoot.jsp”
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>页脚</title>
<link type="text/css" href="../css/css.css" rel="stylesheet" />
</head>
<body>
<!--这是页脚-->
<div class="xinren">
<div class="width1190">
<table>
<tr>
<td>
<dl style="background:url(../images/icon1.jpg) left center no-repeat;">
<dt>承诺</dt>
<dd>真实可信100%真房源<br />链家承诺,假一赔百</dd>
</dl>
</td>
<td>
<dl style="background:url(../images/icon2.jpg) left center no-repeat;">
<dt>权威</dt>
<dd>独家房源 覆盖全城<br />房源信息最权威覆盖最广</dd>
</dl>
</td>
<td>
<dl style="background:url(../images/icon3.jpg) left center no-repeat;">
<dt>信赖</dt>
<dd>万名置业顾问 专业服务<br />百万家庭的信赖之选</dd>
</dl>
</td>
<td>
<dl style="background:url(../images/icon4.jpg) left center no-repeat;">
<dt>安全</dt>
<dd>安心承诺 保驾护航<br />多重风险防范机制 无后顾之忧</dd>
</dl>
</td>
</tr>
</table>
<div class="clears"></div>
</div><!--width1190/-->
</div><!--xinren/-->
<div class="footer">
<div class="width1190">
<!-- FIXME 这里把各个连接更换-->
<div class="fl"><a href="/index.jsp" target="_blank"><strong>易居平台</strong></a><a href="#">关于我们</a><a href="#">联系我们</a><a href="#" target="_blank">个人中心</a></div>
<div class="fr">
<dl>
<!-- FIXME 这里把图片更换-->
<dt><img src="../images/erweima.png" width="76" height="76" /></dt>
<dd>微信扫一扫<br />房价点评,精彩发布</dd>
</dl>
<dl>
<dt><img src="../images/erweima.png" width="76" height="76" /></dt>
<dd>微信扫一扫<br />房价点评,精彩发布</dd>
</dl>
<div class="clears"></div>
</div>
<div class="clears"></div>
</div><!--width1190/-->
</div><!--footer/-->
<div class="copy">Copyright@ 2019 易居住房交易平台 鄂ICP备19009914号-1 技术支持:<a target="_blank" href="#">中软国际</a> </div>
</body>
</html>
“basehead.jsp”
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>页头</title>
<!-- 下面是几个导入的包-->
<link type="text/css" href="../css/css.css" rel="stylesheet" />
<script type="text/javascript" src="../js/js.js"></script>
</head>
<body>
<!--头部最上方的框-->
<div class="header">
<div class="width1190">
<div class="fl" style="font-size: 14px">您好,欢迎来到<a href="../index.jsp">易居住房信息平台!</a></div>
<div class="fr">
<a href="#" style="font-size: 14px" target="_blank"><strong>登录</strong></a> |
<a href="#" style="font-size: 14px" target="_blank"><strong>注册</strong></a>
<a style="font-size: 14px">欢迎使用</a> |
<a href="#" style="font-size: 14px" target="_blank"><strong>个人中心</strong></a> |
<a href="#" style="font-size: 14px"><strong>退出</strong></a> |
<a href="javascript:;" onclick="" style="font-size: 14px">加入收藏</a> |
<a href="javascript:;" onclick="" style="font-size: 14px">设为首页</a>
</div>
<div class="clears"></div>
</div><!--width1190/-->
</div>
<!--头部最上方的框-->
</body>
</html>
“details.jsp”
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>房源详情页</title>
<%--导入CSS文件--%>
<link type="text/css" href="../css/css.css" rel="stylesheet" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Author" contect="http://www.webqin.net">
<link rel="shortcut icon" href="../images/favicon.ico" />
<scrip src="../js/jquery-2.1.1.min.js"></scrip>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/js.js"></script>
</head>
<body>
<!--头部最上方的框-->
<jsp:include page="${pageContext.request.contextPath}/pages/basehead.jsp"></jsp:include>
<!--头部最上方的框-->
<!--Logo栏和手机号栏-->
<div class="logo-phone">
<div class="width1190">
<table align="center" width="100%">
<tr>
<td>
<h1 class="logo">
<a href="../index.jsp">
<img src="../images/logo.png" width="163" height="59" />
</a>
</h1>
</td>
<td align="center">
<div class="phones"><strong>000-00000000</strong></div>
<div class="clears"></div>
</td>
</tr>
</table>
</div><!--width1190/-->
</div><!--logo-phone/-->
<!--Logo栏和手机号栏 END-->
<!--导航栏-->
<div class="list-nav">
<div class="width1190">
<ul class="nav">
<li><a href="../index.jsp">首页</a></li>
<li><a href="${pageContext.request.contextPath}/house/searchHouseViewByType.do?houseType=0¤tPage=1">新房</a></li>
<li><a href="${pageContext.request.contextPath}/house/searchHouseViewByType.do?houseType=1¤tPage=1">二手房</a></li>
<li><a href="${pageContext.request.contextPath}/house/searchHouseViewByType.do?houseType=2¤tPage=1">租房</a></li>
<li class="zhiding"><a href="#">指定购房</a></li>
<li><a href="${pageContext.request.contextPath}/pages/housePost1.jsp">发布房源</a></li>
<li><a href="#">公告中心</a></li>
<li><a href="#">关于我们</a></li>
<div class="clears"></div>
</ul><!--nav-->
<div class="clears"></div>
</div><!--width1190-->
</div><!--list-nav-->
<!--导航栏End-->
<div class="content">
<div class="width1190">
<p style="font-size: 16px">当前位置:<a href="../index.jsp">首页</a> >>
<a href="/house/todetails.do?house_id=${houseInfo.houseId}">房源详情</a>
</p>
</div>
</div>
<%--显示房屋详情--%>
<div class="content">
<div class="width1190" style="width:1000px;">
<div class="proImg fl">
<img src="http://image.cxhit.com/${houseInfo.houseHeadimg}" />
</div><!--proImg/-->
<div style="width:535px;margin:30px 0;float: right;">
<h3 class="proTitle">${houseInfo.houseTitle} </h3>
<div class="proText1">
<table width="90%" align="left" cellspacing="5" cellpadding="5" style="font-size: 130%">
<tr>
<td>房屋编号:<a name="house_id">${houseInfo.houseId}</a></td>
<td>房屋性质:${houseInfo.houseNature}</td>
</tr>
<tr>
<td>装 修:${houseInfo.houseDecorate}</td>
<td>售 价:${houseInfo.housePrice}${houseInfo.priceUnit}</td>
</tr>
<tr>
<td>面 积:${houseInfo.houseArea}㎡</td>
<td>户 型:${houseInfo.houseLayout}</td>
</tr>
<tr>
<td>朝 向:${houseInfo.houseTurn}</td>
<td>配套电梯:
<c:choose>
<c:when test="${houseInfo.houseLift == 1}" >有</c:when>
<c:when test="${houseInfo.houseLift == 0}" >无</c:when>
<c:otherwise>未知</c:otherwise>
</c:choose>
</td>
</tr>
<tr>
<td>房屋类型:${houseInfo.houseModel}</td>
<td>楼 层:${houseInfo.houseFloor}层/${houseInfo.floorAll}层</td>
</tr>
<tr>
<td>建造年份:${houseInfo.houseYear}</td>
<td>居住期限:${houseInfo.houseValid} </td>
</tr>
<tr>
<td colspan="2">所在小区:${houseInfo.houseAddress}</td>
</tr>
<%--<tr><td colspan="2"> </td></tr>--%>
</table>
</div>
<div class="xun-car">
<input class="pricebutton" type="button" value="¥${houseInfo.housePrice}${houseInfo.priceUnit}">
<input class="collectbutton" type="button" value="关注房源">
<%--<a href="javascript:;" class="xwjg">¥<strong>${houseInfo.house_price}</strong>${houseInfo.price_unit}</a>--%>
<%--<a href="/user/follow.do?house_id=${houseInfo.house_id}" class="projrgwc">关注房源</a>--%>
</div>
</div><!--proText/-->
<div class="clears"></div>
</div><!--width1190/-->
<%--下面是房源详情页--%>
<div class="proBox" style="width:1000px;margin:10px auto;">
<div class="proEq">
<ul class="fl">
<li class="proEqCur">房源图片</li>
<li>小区介绍</li>
<li>用户评价</li>
</ul>
<div class="clears"></div>
</div><!--proEq/-->
<div class="proList">
<h2 class="title"><a style="color:#F1323B"> </a>房源平面图</h2>
<br>
<c:if test="${!empty houseInfo.housePlanimg1}">
<img src="http://image.cxhit.com/${houseInfo.housePlanimg1}" style="width: 286px;height: 188px"/>
</c:if>
<c:if test="${!empty houseInfo.housePlanimg2}">
<img src="http://image.cxhit.com/${houseInfo.housePlanimg2}" style="width: 286px;height: 188px"/>
</c:if>
<h2 class="title"><a style="color:#F1323B"> </a>房源内饰图</h2>
<br>
<c:if test="${!empty houseInfo.houseImg1}">
<img src="http://image.cxhit.com/${houseInfo.houseImg1}" style="width: 286px;height: 188px"/>
</c:if>
<c:if test="${!empty houseInfo.houseImg2}">
<img src="http://image.cxhit.com/${houseInfo.houseImg2}" style="width: 286px;height: 188px"/>
</c:if>
<c:if test="${!empty houseInfo.houseImg3}">
<img src="http://image.cxhit.com/${houseInfo.houseImg3}" style="width: 286px;height: 188px"/>
</c:if>
<c:if test="${!empty houseInfo.houseImg4}">
<img src="http://image.cxhit.com/${houseInfo.houseImg4}" style="width: 286px;height: 188px"/>
</c:if>
<c:if test="${!empty houseInfo.houseImg5}">
<img src="http://image.cxhit.com/${houseInfo.houseImg5}" style="width: 286px;height: 188px"/>
</c:if>
<c:if test="${!empty houseInfo.houseImg6}">
<img src="http://image.cxhit.com/${houseInfo.houseImg6}" style="width: 286px;height: 188px"/>
</c:if>
</div><!--proList/-->
<div class="proList">
暂无信息...
</div>
<div class="proList">
暂无评论……
</div>
<!--proList/-->
</div><!--proBox/-->
</div><!--content/-->
<%--引入页脚--%>
<iframe src="../pages/basefoot.jsp"frameborder="0" scrolling="no" height="263px" width="100%"></iframe>
</body>
</html>
“newhouse.jsp”
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%@ page import="java.util.List" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %><%--
Created by IntelliJ IDEA.
User: 36353
Date: 2019-07-04
Time: 22:54
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
<title>新房房源列表</title>
<%--导入CSS文件--%>
<link type="text/css" href="../css/css.css" rel="stylesheet"/>
<%--导航栏的JS--%>
<script type="text/javascript" src="../js/js.js"></script>
<script type="text/javascript" src="../js/jquery.js"></script>
<%--搜索框的css--%>
<link type="text/css" href="../css/searchInputStyle.css" rel="stylesheet"/>
<link type="text/css" href="../css/searchReset.css" rel="stylesheet"/>
<script type="text/javascript" src="js/jquery2.min.js"></script>
</head>
<body>
<!--头部最上方的框-->
<jsp:include page="../pages/basehead.jsp"></jsp:include>
<!--头部最上方的框-->
<!--Logo栏和手机号栏-->
<div class="logo-phone">
<div class="width1190">
<table align="center" width="100%">
<tr>
<td>
<h1 class="logo"><a href="../index.jsp"><img src="../images/logo.png" width="163" height="59"/></a>
</h1>
</td>
<td align="center">
<div class="phones"><strong>000-0000000</strong></div>
<div class="clears"></div>
</td>
</tr>
</table>
</div><!--width1190/-->
</div><!--logo-phone/-->
<!--Logo栏和手机号栏-->
<!--导航栏-->
<div class="list-nav">
<div class="width1190">
<ul class="nav">
<li><a href="#">首页</a></li>
<li><a href="#">新房</a></li>
<li><a href="#">二手房</a></li>
<li><a href="#">租房</a></li>
<li class="zhiding"><a href="#">指定购房</a></li>
<li><a href="#">发布房源</a></li>
<li><a href="#">公告中心</a></li>
<li><a href="#">关于我们</a></li>
<div class="clears"></div>
</ul><!--nav-->
<div class="clears"></div>
</div><!--width1190-->
</div><!--list-nav-->
<!--导航栏End-->
<!--Logo栏和手机号栏-->
<hr width="1280px">
<%--<div class="content">--%>
<div class="width1190">
<p style="font-size: 16px">当前位置:<a href="../index.jsp">首页</a> >> <a
href="#">新房房源</a></p>
</div>
<%--</div>--%>
<%--房源列表--%>
<div class="content">
<div class="width1190">
<form action="" method="get" class="pro-search">
<div class="paixu">
<strong>排序:</strong>
<a href="javascript:;" class="pai-cur">默认</a>
<a href="javascript:;">价格 ∨</a>
<a href="javascript:;">最新 ∨</a>
</div>
</form><!--pro-search/-->
</div><!--width1190/-->
<div class="width1190">
<div class="pro-left">
<%--房屋信息分页显示--%>
<c:forEach var="house" items="${pageInfo.list}">
<dl>
<dt><a href="#"><img src="http://image.cxhit.com/${house.houseHeadimg}" style="width:286px;height:188px"
width="286" height="188"/></a></dt>
<dd>
<h3><a href="#">${house.houseTitle}</a></h3>
<div class="pro-wei">
<img src="http://image.cxhit.com/${house.houseAddress}" width="12" height="16" style="width:12px;height:16px"/>
<strong class="red">${house.houseAddress}</strong>
</div>
<div class="pro-fang">${house.houseLayout} ${house.houseArea}平 ${house.houseTurn} ${house.houseFloor}层/${house.floorAll}层</div>
<div class="pra-fa">发布人:${house.trueName}先生 发布时间:${house.date}</div>
</dd>
<div class="price">¥ <strong>${house.housePrice}</strong><span
class="font12">${house.priceUnit}</span></div>
<div class="clears"></div>
</dl>
</c:forEach>
<%--分页按钮--%>
<div class="pull-right">
<ul class="pagination">
<li><a href="#">首页</a></li>
<li>
<a href="#">上一页</a>
</li>
<li>
<a href="#">1</a>
<a href="#">2</a>
<a href="#">3</a>
</li>
<li>
<a href="#">下一页</a>
</li>
<li>
<a href="#"
aria-label="Next">尾页</a></li>
</ul>
</div><!--底部分页栏-->
</div><!--pro-left/-->
<div class="pro-right">
<h2 class="right-title">推荐房源</h2>
<div class="right-pro">
<c:forEach var="randomHouse" items="#">
<dl>
<dt>
<a href="#"><img
src="http://image.cxhit.com/${house.houseHeadimg}"
style="width: 135px; height: 88px"/></a></dt>
<dd>
<h3>
<a href="#">${randomHouse.houseTitle}</a>
</h3>
<div class="pro-fang">${randomHouse.houseLayout} ${randomHouse.houseArea}平
朝${randomHouse.houseTurn}</div>
<div class="right-price">${randomHouse.housePrice}${randomHouse.priceUnit}</div>
</dd>
</dl>
</c:forEach>
</div><!--right-pro/-->
</div><!--pro-right/-->
<div class="clears"></div>
</div><!--width1190/-->
</div><!--content/-->
<%--显示页脚--%>
<jsp:include page="../pages/basefoot.jsp"></jsp:include>
</body>
</html>