IT俱乐部 Jsp JSP实时显示当前系统时间的四种方式示例解析

JSP实时显示当前系统时间的四种方式示例解析

JSP显示当前系统时间的四种方式:

第一种java内置时间类实例化对象:

1
2
3
4
5
<base href="<%=basePath%>" rel="external nofollow"><title>My JSP 'time4.jsp' starting page</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page">

第二种方式使用JSP内置USEBEAN实例化时间类:

1
2
3
4
5
6
7
<base href="<%=basePath%>" rel="external nofollow"><title>显示系统时间方法一:</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><usebean id="time" class="java.util.Date"></usebean>
  现在时间:

第三种方式使用JSP USEBEAN type与beanName配对使用:

1
2
3
4
5
6
7
<base href="<%=basePath%>" rel="external nofollow"><title>My JSP 'time2-useBean-type-beanName.jsp' starting page</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><usebean id="time" type="java.io.Serializable" beanname="java.util.Date"></usebean>
  现在时间:

第四种方式使用JSP setproperty设置属性:

1
2
3
4
5
6
7
8
<base href="<%=basePath%>" rel="external nofollow"><title>My JSP 'time3-setproperty.jsp' starting page</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page">
jsp:setproperty 实例<hr><usebean id="time" class="java.util.Date"><setproperty name="time" property="hours" param="hh"></setproperty><setproperty name="time" property="minutes" param="mm"></setproperty><setproperty name="time" property="seconds" param="ss"></setproperty></usebean><br>
设置属性后的时间:${time} }
<br>

所有代码均能直接复制到MYECLIPSE2010

到此这篇关于JSP实时显示当前系统时间的四种方式示例解析的文章就介绍到这了,更多相关JSP实时显示当前系统时间内容请搜索IT俱乐部以前的文章或继续浏览下面的相关文章希望大家以后多多支持IT俱乐部!

本文收集自网络,不代表IT俱乐部立场,转载请注明出处。https://www.2it.club/code/jsp/2800.html
上一篇
下一篇
联系我们

联系我们

在线咨询: QQ交谈

邮箱: 1120393934@qq.com

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部