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>
  • 相关阅读:
    翻译:《实用的Python编程》03_04_Modules
    翻译:《实用的Python编程》03_03_Error_checking
    翻译:《实用的Python编程》03_02_More_functions
    翻译:《实用的Python编程》03_01_Script
    翻译:《实用的Python编程》03_00_Overview
    翻译:《实用的 Python 编程》02_07_Objects
    翻译:《实用的Python编程》02_06_List_comprehension
    生成器
    python编码
    python迭代器
  • 原文地址:https://www.cnblogs.com/jimorulang/p/5532701.html
Copyright © 2011-2022 走看看