?? touch.jsp
字號:
<%@ page import="java.io.File" errorPage="err.jsp" %>
<%@ taglib uri="gnat" prefix="gnat" %>
<%--
Use the Servlet 2.2+ temporary working directory to demo some file stuff.
Makes it easier because the user doesn't have to configure anything and I
don't have to worry about file system and user permissions for the demo.
See section 3.7 of Servlet 2.3 spec for description of this attribute.
--%>
<%! File tempdir = null; %>
<% tempdir = (File)application.getAttribute("javax.servlet.context.tempdir"); %>
<html>
<head>
<title>Gnat JSP Taglib</title>
<link type="text/css" href="examples.css" rel="stylesheet">
</head>
<body>
<h1>Gnat Taglib: touch</h1>
<%-- Until JRun and Jasper escape String literals nested in custom tag attributes
properly, it's best to declare them as variables and then use their variable
names rather than the literal strings. The multitude of double quotations
seems to confuse JRun (3.0, SP1) and Jasper (3.3.dev), though JRun can deal
with them if the quotes around the whole attribute are removed.
--%>
<%-- Name of file to create in demo --%>
<% final String foo = "/touched-file.txt"; %>
<% final String foo2 = "/second-touched-file.txt"; %>
<p>Changes the modification time of a file and possibly creates it at the same time.
The touch examples in this page are created in <b><%= tempdir %></b></p>
<p class="tag"><gnat:touch file="/file/to/touch" millis="modtime in millis" datetime="modtime date format"/></p>
<gnat:touch file="<%= tempdir+foo %>"/>
<p>example 1 - millis can be assigned dynamically, using an expression:</p>
<p class="tag"><gnat:touch file="<%= tempdir+foo %>" millis="<%= new java.util.Date().getTime() %>" />
<gnat:touch file="<%= tempdir+foo %>" millis="<%= new java.util.Date().getTime() %>" />
<p>example 2 - Or millis can be assigned statically, using milliseconds since midnight Jan 1 1970...</p>
<p>The example below sets the last modified time as 12/24/2000 21:15pm</p>
<p class="tag"><gnat:touch file="<%= tempdir+foo %>" millis="977710526363" />
<gnat:touch file="<%= tempdir+foo %>" millis="977710526363" />
<p>example 3 - Or millis can be assigned statically, using a formatted date. The datetime variable must be set in format: MM/DD/YYYY HH:MM AM or PM.</p>
<p class="tag"><gnat:touch file="<%= tempdir+foo2 %>" datetime="06/28/1983 2:02 pm" /></p>
<gnat:touch file="<%= tempdir+foo2 %>" datetime="06/28/1983 2:02 pm" />
</body>
</html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -