从servlet跳到jsp页面,并用jstl 进行判断和显示方法

以上是list集合的遍历方式

租房网的detailsServlet

public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        String id=request.getParameter("id");
        IHouseDAO hd=new HouseDAO();
        House house=hd.findById(Integer.parseInt(id));
        request.getSession().setAttribute("house", house);
        request.getRequestDispatcher("page/details.jsp").forward(request, response);
        out.flush();
        out.close();
    }

 

租房网的detail.jsp页面

 

 

<c:if test="${sessionScope.house ne null}">
<DIV class=lefter>
<H1>${house.getTitle()}</H1>
<div class=subinfo><div id="myclock"></div></DIV>
<div class=houseinfo>
<P>户  型:<SPAN>${house.getTypes().getName()}</SPAN></P>
<P>面  积:<SPAN>${house.getFloorage()}m<SUP>2</SUP></SPAN></P>
<P>位  置:<SPAN>${house.getStreet().getDistrict().getName()}${house.getStreet().getName()}</SPAN></P>
<P>联系方式:<SPAN>${house.getContact()}</SPAN></P>
</div>
</div>
</c:if>

 

时钟的js实现

<script type="text/javascript">
function clock_24h()
{
 var today = new Date(); //获得当前时间
 //获得年、月、日,Date()函数中的月份是从0-11计算
 var year = today.getFullYear();  //
 var month = today.getMonth()+1;//
 var date = today.getDate();//
 var hour = today.getHours();  //获得小时、分钟、秒
 var minute = today.getMinutes();
 var second = today.getSeconds();
 
 
  /*设置div的内容为当前时间*/
 document.getElementById("myclock").innerHTML="<h2>"+year+"-"+month+"-"+date+"&nbsp;"+hour+":"+minute+":"+second+"&nbsp;"+"</h2>";

}
/*使用setInterval()每间隔指定毫秒后调用clock_12h()*/
var myTime = setInterval("clock_24h()",1000);

</script>

 

转载于:https://www.cnblogs.com/jimorulang/p/5532701.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值