jsp页面时间获取并判断

来源:互联网 发布:网络小贷 资金来源 编辑:程序博客网 时间:2024/06/11 22:07

赋值
<%
Date date = new Date();
request.setAttribute("date", date);
%>

取值${date}



(1)JSP页面:
      request.setAttribute("date",new Date());

(2) EL表达式 JSP 显示服务器上的时间:
      ${date}

(3)如果你仅仅只想在获得本地上的时间,你只要用js就可以获得了
<script>
  var date =new Date();
//这里的date 是你打开jsp页面的本地时间,和服务器时间是有区别的
</script>


时间比较

     <c:choose>
      <c:when test="${date.before(s.startDateTime)}">
                                   未开始
      </c:when>
       <c:when test="${date.after(s.endDateTime)}">
                                   已结束
      </c:when>
      <c:otherwise>进行中</c:otherwise>
    



本文出自 “点滴积累” 博客,请务必保留此出处http://tianxingzhe.blog.51cto.com/3390077/1675103

0 0