色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁技術(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
主站蜘蛛池模板: 免费一级欧美毛片 | 性欧美成人依依影院 | 国产午夜精品久久久久小说 | 亚洲黄色在线视频 | 日韩a毛片免费全部播放完整 | 韩国一级毛片大全女教师 | 中文字幕一二三区 | 日韩一区三区 | 免费一级网站免费 | 亚州免费一级毛片 | 亚洲国产精品自产拍在线播放 | 2021国产成人精品久久 | 中文字幕乱码系列免费 | 久久久久久免费一区二区三区 | 国产一区日韩二区欧美三 | 日本人一级毛片视频 | 欧美一区二区三区国产精品 | 美女扒开双腿让男人爽透视频 | 亚洲激情黄色 | 深夜福利爽爽爽动态图 | 亚洲天堂久久久 | 久久精品久久精品国产大片 | 91碰碰 | 日韩欧美综合在线二区三区 | 欧美成人午夜在线全部免费 | 日韩精品中文字幕视频一区 | 一级作爱视频免费观看 | 涩涩国产精品福利在线观看 | 亚洲性天堂 | 99久久精品免费观看区一 | 久草在线视频中文 | 国产老妇k | 碰碰碰免费公开在线视频 | 亚洲三级网 | 亚洲国产一区二区三区四区 | 九九香蕉| avtt亚洲一区中文字幕 | 精品九九久久国内精品 | 成人性色生活片免费网 | 免费看欧美日韩一区二区三区 | 亚洲国产精品日韩在线观看 |