旅游门户网站03
旅游线路的详情展示
Servlet
public void detail(HttpServletRequest request,HttpServletResponse response) throws IOException {
String rid_ = request.getParameter("rid");
Integer rid = Integer.parseInt(rid_);
Route route = service.findRouteByid(rid);
writeResponse(route,response);
}
service:
@Override
public Route findRouteByid(Integer rid) {
Route route =routeDao.findRoutrByid(rid);
Category category = categoryDao.findCnameByid(route.getCid());
route.setCategory(category);
Seller seller = sellerDao.findSellerByid(route.getSid());
route.setSeller(seller);
List<RouteImg> imgs = routeImgDao.findImgsByRid(rid);
route.setImages(imgs);
return route;
}
Dao
@Override
public Route findRoutrByid(Integer rid) {
Route route = jdbcTemplate.queryForObject("select * from tab_route where rid = ?", new BeanPropertyRowMapper<Route>(Route.class), rid);
return route;
}
@Override
public Category findCnameByid(Integer cid) {
Category category = jdbcTemplate.queryForObject("select * from tab_category where cid = ?", new BeanPropertyRowMapper<Category>(Category.class), cid);
return category;
}
@Override
public List<RouteImg> findImgsByRid(Integer rid) {
List<RouteImg> list = jdbcTemplate.query("select * from tab_route_img where rid = ?", new BeanPropertyRowMapper<RouteImg>(RouteImg.class), rid);
return list;
}
$(document).ready(function() {
var rid=getParameter("rid");
var currentPage =getParameter("currentPage");
$.get("route/detail",{rid:rid},function (route) {
$("#rname").html(route.rname);
$("#id").html(route.category.cname);
$("#name").html(route.rname);
$("#sy").prop("href","http://localhost:80/sumang/index.html");
$("#name").prop("href","http://localhost:80/sumang/route_detail.html?rid="+rid);
$("#id").prop("href","http://localhost:80/sumang/route_list.html?cid="+route.category.cid+'¤tPage='+currentPage);
$("#rIntro").html(route.routeIntroduce);
$("#sname").html("经营商家 :"+route.seller.sname);
$("#sphone").html("咨询电话 : "+route.seller.consphone);
$("#saddress").html("地址 : "+route.seller.address);
$("#rprice").html(route.price);
$("#rcount").html("已收藏"+route.count+"次");
var images=route.images;
$("#bigImg").attr("src",images[0].bigPic)
var lis=' <a class="up_img up_img_disable"></a>';
for (var i=0;i<images.length;i++){
if (i>=4){
lis+=' <a title="" class="little_img" data-bigpic='+images[i].bigPic+' style="display:none">\n' +
' <img src='+images[i].smallPic+'>\n' +
' </a>';
}
else {
lis+=' <a title="" class="little_img" data-bigpic='+images[i].bigPic+' style="">\n' +
' <img src='+images[i].smallPic+'>\n' +
' </a>';
}
}
lis+='<a class="down_img down_img_disable" style="margin-bottom: 0;"></a>';
$("#small").html(lis);
goImg();
},"json");