⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ls.jsp

📁 jakarta-taglibs
💻 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: ls</h1>

<p>Gets a directory listing as a String array named "list."
</p>

<p>example 1 - ls</p>
<br />&lt;ul&gt;
<br />&lt;gnat:ls dir="&lt;%= tempdir.toString() %&gt;" id="list"&gt;
<br />   &lt;li&gt;&lt;i&gt;&lt;font color="blue"&gt;&lt;jsp:getProperty name="list" property="item" /&gt;&lt;/font&gt;&lt;/i&gt;&lt;/li&gt;
<br />&lt;/gnat:ls&gt;
<br />&lt;/ul&gt;
<%-- Be careful with this tag -- you can use it to list the contents of any directory
     on your filesytem unless you take security measures with a Java policy file. --%>

<h3>looping through a directory and formatting the file names in HTML.</h3>
<p>File listing for <%= tempdir %></p>

<ul>
<gnat:ls dir="<%= tempdir.toString() %>" id="list">
   <li><i><font color="blue"><jsp:getProperty name="list" property="item" /></font></i></li>
</gnat:ls>
</ul>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -