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

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

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

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

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

第一種java內(nèi)置時(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>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配對使用:

<%@ 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)容請搜索以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持!

標(biāo)簽: JSP
主站蜘蛛池模板: 日本午夜vr影院新入口 | 欧美视频一区二区在线观看 | 成人午夜久久 | 成人国产精品视频 | a级毛片免费观看视频 | 国产不卡在线视频 | 国产麻豆入在线观看 | 国产一二三区在线观看 | 美女张开腿让男人桶的 视频 | 九九热视频在线播放 | 亚洲午夜精品一区二区 | 国产三级视频在线 | 日本韩经典三级在线播放 | 自怕偷自怕亚洲精品 | 欧美日韩国产va另类 | 黄 色 免费网 站 成 人 | 久草网在线视频 | 美女美女大片黄a大片 | 亚洲欧美日韩在线播放 | 日本九六视频 | 特色毛片 | 高清欧美性狂猛bbbbbbxxxx | 一区二区日韩欧美 | 在线免费自拍 | 欧美大片欧美毛片大片 | 亚洲视频中文字幕在线观看 | 欧美久久视频 | 香蕉视频在线观看黄 | 亚洲乱码一二三四五六区 | 亚洲制服丝袜美腿亚洲一区 | 日韩一级 | 国产三及 | 精品视频在线观看 | 国产成人在线观看免费网站 | 91精品乱码一区二区三区 | 欧美福利一区二区三区 | 日本红怡院在线 | 亚洲成a人片毛片在线 | 久久精品vr中文字幕 | 99九九国产精品免费视频 | 毛片在线免费观看网站 |