濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > JSP實(shí)時(shí)顯示當(dāng)前系統(tǒng)時(shí)間的四種方式示例解析

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

熱門標(biāo)簽:南通通訊外呼系統(tǒng)產(chǎn)品介紹 海外圖書館地圖標(biāo)注點(diǎn) 電話機(jī)器人需要使用網(wǎng)絡(luò)嗎 外呼系統(tǒng)使用方法 電銷機(jī)器人免培訓(xùn) 如何看懂地圖標(biāo)注點(diǎn) 給地圖標(biāo)注得傭金 自繪地圖標(biāo)注數(shù)據(jù) 潤(rùn)滑油銷售電銷機(jī)器人

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" class="java.util.Date"/>
  	現(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" class="java.util.Date">
  	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)文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • jsp實(shí)現(xiàn)頁(yè)面實(shí)時(shí)顯示當(dāng)前系統(tǒng)時(shí)間的方法

標(biāo)簽:大連 南京 黃石 廣州 貸款邀約 樂(lè)山 內(nèi)江 銅川

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《JSP實(shí)時(shí)顯示當(dāng)前系統(tǒng)時(shí)間的四種方式示例解析》,本文關(guān)鍵詞  JSP,實(shí)時(shí),顯示,當(dāng)前,系統(tǒng),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《JSP實(shí)時(shí)顯示當(dāng)前系統(tǒng)時(shí)間的四種方式示例解析》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于JSP實(shí)時(shí)顯示當(dāng)前系統(tǒng)時(shí)間的四種方式示例解析的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    林口县| 伊宁县| 蒙城县| 容城县| 仁怀市| 航空| 墨玉县| 马鞍山市| 肇州县| 滨州市| 龙州县| 鸡西市| 施甸县| 巩义市| 河南省| 吴旗县| 永嘉县| 广南县| 成安县| 鹤山市| 永川市| 法库县| 遂溪县| 富民县| 横山县| 华阴市| 仁怀市| 普定县| 南安市| 县级市| 南召县| 西乌珠穆沁旗| 宜宾市| 东兰县| 沈丘县| 武川县| 巴林左旗| 利辛县| 吐鲁番市| 安多县| 二连浩特市|