国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術(shù)文章
文章詳情頁

JSP實(shí)時(shí)顯示當(dāng)前系統(tǒng)時(shí)間的四種方式示例解析

瀏覽:245日期:2022-06-08 09:37:05

JSP顯示當(dāng)前系統(tǒng)時(shí)間的四種方式:

第一種java內(nèi)置時(shí)間類實(shí)例化對(duì)象:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
	-->
 
 </head>
 
 <body>
  <%
  java.text.SimpleDateFormat simpleDateFormat = new java.text.SimpleDateFormat( 
   "yyyy-MM-dd HH:mm:ss"); 
  java.util.Date currentTime = new java.util.Date(); 
  String time = simpleDateFormat.format(currentTime).toString();
  out.println("當(dāng)前時(shí)間為:"+time);
   %>
   
 </body>
</html>

第二種方式使用JSP內(nèi)置USEBEAN實(shí)例化時(shí)間類:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
  
  <title>顯示系統(tǒng)時(shí)間方法一:</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">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
	-->
 
 </head>
 
 <body>
  <jsp:useBean id="time"/>
  	現(xiàn)在時(shí)間:<%=time%>
 </body>
</html>

第三種方式使用JSP USEBEAN type與beanName配對(duì)使用:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
	-->
 
 </head>
 
 <body>
   <jsp:useBean id="time" type="java.io.Serializable" beanName="java.util.Date"/>
  	現(xiàn)在時(shí)間:<%=time%>
 </body>
</html>

第四種方式使用JSP setproperty設(shè)置屬性:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
	-->
 
 </head>
 
 <body>
  jsp:setproperty 實(shí)例<hr>
  <jsp:useBean id="time">
  	<jsp:setProperty name="time" property="hours" param="hh"/>
  	<jsp:setProperty name="time" property="minutes" param="mm"/>
  	<jsp:setProperty name="time" property="seconds" param="ss"/>
  </jsp:useBean>
  <br>
  設(shè)置屬性后的時(shí)間:${time} }
  <br>
  
 </body>
</html>

所有代碼均能直接復(fù)制到MYECLIPSE2010

到此這篇關(guān)于JSP實(shí)時(shí)顯示當(dāng)前系統(tǒng)時(shí)間的四種方式示例解析的文章就介紹到這了,更多相關(guān)JSP實(shí)時(shí)顯示當(dāng)前系統(tǒng)時(shí)間內(nèi)容請(qǐng)搜索以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持!

標(biāo)簽: JSP
主站蜘蛛池模板: 日本韩国台湾香港三级 | 日韩精品视频在线 | 久草久在线 | 免费国产成人手机在线观看 | 午夜影院福利社 | 中文字幕成人免费高清在线 | 久久福利网站 | 久久精品国产99久久久 | 久久精品a | 国产精品一区在线免费观看 | 日本黄网站高清色大全 | 久久99精品视免费看 | 国产精品久久国产三级国电话系列 | a级毛片毛片免费很很综合 a级毛片免费 | 99精品在线观看 | 成人怡红院 | 国产欧美曰韩一区二区三区 | 亚洲欧美男人天堂 | 久草观看视频 | 欧美精品久久久久久久影视 | 久久影院在线观看 | 国产首页精品 | 欧美视频一区二区三区 | 日本高清va不卡视频在线观看 | 99国产国人青青视频在线观看 | 99国产高清久久久久久网站 | 久久青草免费免费91线频观看 | 尤物蜜芽福利国产污在线观看 | 欧美色欧美色 | 日韩一级视频 | 最新亚洲人成网站在线影院 | 久草在线免费看 | 精品久久久日韩精品成人 | 成人韩免费网站 | 精品国产三级v | 九一精品 | 九九色综合网 | 一级片高清 | 8050网午夜一级毛片免费不卡 | 日韩在线视频免费 | 国产精品v在线播放观看 |