zoukankan      html  css  js  c++  java
  • 从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>
  • 相关阅读:
    STM32与FPGA通信写数据出错问题解决方法
    Altium Designer 8.0不为人知的27个技巧
    modbus详尽中文资料、软件、代码
    STM32中断与NVIC概览
    FatFs读写SD卡出现FR_NO_FILESYSTEM解决方法.
    用两个低位数的DA合成高位数的DA
    4-20mA电流转换电路分析
    C语言写的俄罗斯方块
    无源RS232转RS485(转)
    稻盛和夫写的六项精进指的是什么
  • 原文地址:https://www.cnblogs.com/jimorulang/p/5532701.html
Copyright © 2011-2022 走看看