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俱乐部!