刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 1 | <html><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Apache Tomcat 7 (7.0.77) - Default Servlet Reference</title><meta name="author" content="Tim Funk"><style type="text/css" media="print">
|
| 2 | .noPrint {display: none;}
|
| 3 | td#mainBody {width: 100%;}
|
| 4 | </style><style type="text/css">
|
| 5 | code {background-color:rgb(224,255,255);padding:0 0.1em;}
|
| 6 | code.attributeName, code.propertyName {background-color:transparent;}
|
| 7 |
|
| 8 |
|
| 9 | table {
|
| 10 | border-collapse: collapse;
|
| 11 | text-align: left;
|
| 12 | }
|
| 13 | table *:not(table) {
|
| 14 | /* Prevent border-collapsing for table child elements like <div> */
|
| 15 | border-collapse: separate;
|
| 16 | }
|
| 17 |
|
| 18 | th {
|
| 19 | text-align: left;
|
| 20 | }
|
| 21 |
|
| 22 |
|
| 23 | div.codeBox pre code, code.attributeName, code.propertyName, code.noHighlight, .noHighlight code {
|
| 24 | background-color: transparent;
|
| 25 | }
|
| 26 | div.codeBox {
|
| 27 | overflow: auto;
|
| 28 | margin: 1em 0;
|
| 29 | }
|
| 30 | div.codeBox pre {
|
| 31 | margin: 0;
|
| 32 | padding: 4px;
|
| 33 | border: 1px solid #999;
|
| 34 | border-radius: 5px;
|
| 35 | background-color: #eff8ff;
|
| 36 | display: table; /* To prevent <pre>s from taking the complete available width. */
|
| 37 | /*
|
| 38 | When it is officially supported, use the following CSS instead of display: table
|
| 39 | to prevent big <pre>s from exceeding the browser window:
|
| 40 | max-width: available;
|
| 41 | width: min-content;
|
| 42 | */
|
| 43 | }
|
| 44 |
|
| 45 | div.codeBox pre.wrap {
|
| 46 | white-space: pre-wrap;
|
| 47 | }
|
| 48 |
|
| 49 |
|
| 50 | table.defaultTable tr, table.detail-table tr {
|
| 51 | border: 1px solid #CCC;
|
| 52 | }
|
| 53 |
|
| 54 | table.defaultTable tr:nth-child(even), table.detail-table tr:nth-child(even) {
|
| 55 | background-color: #FAFBFF;
|
| 56 | }
|
| 57 |
|
| 58 | table.defaultTable tr:nth-child(odd), table.detail-table tr:nth-child(odd) {
|
| 59 | background-color: #EEEFFF;
|
| 60 | }
|
| 61 |
|
| 62 | table.defaultTable th, table.detail-table th {
|
| 63 | background-color: #88b;
|
| 64 | color: #fff;
|
| 65 | }
|
| 66 |
|
| 67 | table.defaultTable th, table.defaultTable td, table.detail-table th, table.detail-table td {
|
| 68 | padding: 5px 8px;
|
| 69 | }
|
| 70 |
|
| 71 |
|
| 72 | p.notice {
|
| 73 | border: 1px solid rgb(255, 0, 0);
|
| 74 | background-color: rgb(238, 238, 238);
|
| 75 | color: rgb(0, 51, 102);
|
| 76 | padding: 0.5em;
|
| 77 | margin: 1em 2em 1em 1em;
|
| 78 | }
|
| 79 | </style></head><body bgcolor="#ffffff" text="#000000" link="#525D76" alink="#525D76" vlink="#525D76"><table border="0" width="100%" cellspacing="0"><!--PAGE HEADER--><tr><td><!--PROJECT LOGO--><a href="http://tomcat.apache.org/"><img src="./images/tomcat.gif" align="right" alt="
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 80 | The Apache Tomcat Servlet/JSP Container
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 81 | " border="0"></a></td><td><h1><font face="arial,helvetica,sanserif">Apache Tomcat 7</font></h1><font face="arial,helvetica,sanserif">Version 7.0.77, Mar 28 2017</font></td><td><!--APACHE LOGO--><a href="http://www.apache.org/"><img src="./images/asf-logo.svg" align="right" alt="Apache Logo" border="0" style="width: 266px;height: 83px;"></a></td></tr></table><table border="0" width="100%" cellspacing="4"><!--HEADER SEPARATOR--><tr><td colspan="2"><hr noshade size="1"></td></tr><tr><!--LEFT SIDE NAVIGATION--><td width="20%" valign="top" nowrap class="noPrint"><p><strong>Links</strong></p><ul><li><a href="index.html">Docs Home</a></li><li><a href="http://wiki.apache.org/tomcat/FAQ">FAQ</a></li><li><a href="#comments_section">User Comments</a></li></ul><p><strong>User Guide</strong></p><ul><li><a href="introduction.html">1) Introduction</a></li><li><a href="setup.html">2) Setup</a></li><li><a href="appdev/index.html">3) First webapp</a></li><li><a href="deployer-howto.html">4) Deployer</a></li><li><a href="manager-howto.html">5) Manager</a></li><li><a href="realm-howto.html">6) Realms and AAA</a></li><li><a href="security-manager-howto.html">7) Security Manager</a></li><li><a href="jndi-resources-howto.html">8) JNDI Resources</a></li><li><a href="jndi-datasource-examples-howto.html">9) JDBC DataSources</a></li><li><a href="class-loader-howto.html">10) Classloading</a></li><li><a href="jasper-howto.html">11) JSPs</a></li><li><a href="ssl-howto.html">12) SSL/TLS</a></li><li><a href="ssi-howto.html">13) SSI</a></li><li><a href="cgi-howto.html">14) CGI</a></li><li><a href="proxy-howto.html">15) Proxy Support</a></li><li><a href="mbeans-descriptors-howto.html">16) MBeans Descriptors</a></li><li><a href="default-servlet.html">17) Default Servlet</a></li><li><a href="cluster-howto.html">18) Clustering</a></li><li><a href="balancer-howto.html">19) Load Balancer</a></li><li><a href="connectors.html">20) Connectors</a></li><li><a href="monitoring.html">21) Monitoring and Management</a></li><li><a href="logging.html">22) Logging</a></li><li><a href="apr.html">23) APR/Native</a></li><li><a href="virtual-hosting-howto.html">24) Virtual Hosting</a></li><li><a href="aio.html">25) Advanced IO</a></li><li><a href="extras.html">26) Additional Components</a></li><li><a href="maven-jars.html">27) Mavenized</a></li><li><a href="security-howto.html">28) Security Considerations</a></li><li><a href="windows-service-howto.html">29) Windows Service</a></li><li><a href="windows-auth-howto.html">30) Windows Authentication</a></li><li><a href="jdbc-pool.html">31) Tomcat's JDBC Pool</a></li><li><a href="web-socket-howto.html">32) WebSocket</a></li></ul><p><strong>Reference</strong></p><ul><li><a href="RELEASE-NOTES.txt">Release Notes</a></li><li><a href="config/index.html">Configuration</a></li><li><a href="api/index.html">Tomcat Javadocs</a></li><li><a href="servletapi/index.html">Servlet Javadocs</a></li><li><a href="jspapi/index.html">JSP 2.2 Javadocs</a></li><li><a href="elapi/index.html">EL 2.2 Javadocs</a></li><li><a href="websocketapi/index.html">WebSocket 1.1 Javadocs</a></li><li><a href="http://tomcat.apache.org/connectors-doc/">JK 1.2 Documentation</a></li></ul><p><strong>Apache Tomcat Development</strong></p><ul><li><a href="building.html">Building</a></li><li><a href="changelog.html">Changelog</a></li><li><a href="http://wiki.apache.org/tomcat/TomcatVersions">Status</a></li><li><a href="developers.html">Developers</a></li><li><a href="architecture/index.html">Architecture</a></li><li><a href="funcspecs/index.html">Functional Specs.</a></li><li><a href="tribes/introduction.html">Tribes</a></li></ul></td><!--RIGHT SIDE MAIN BODY--><td width="80%" valign="top" align="left" id="mainBody"><h1>Default Servlet Reference</h1><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Table of Contents"><!--()--></a><a name="Table_of_Contents"><strong>Table of Contents</strong></a></font></td></tr><tr><td><blockquote>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 82 | <ul><li><a href="#what">What is the DefaultServlet</a></li><li><a href="#where">Where is it declared?</a></li><li><a href="#change">What can I change?</a></li><li><a href="#dir">How do I customize directory listings?</a></li><li><a href="#secure">How do I secure directory listings?</a></li></ul>
|
| 83 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="what"><strong>What is the DefaultServlet</strong></a></font></td></tr><tr><td><blockquote>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 84 | <p>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 85 | The default servlet is the servlet which serves static resources as well
|
| 86 | as serves the directory listings (if directory listings are enabled).
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 87 | </p>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 88 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="where"><strong>Where is it declared?</strong></a></font></td></tr><tr><td><blockquote>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 89 | <p>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 90 | It is declared globally in <i>$CATALINA_BASE/conf/web.xml</i>.
|
| 91 | By default here is it's declaration:
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 92 | </p>
|
| 93 | <div class="codeBox"><pre><code> <servlet>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 94 | <servlet-name>default</servlet-name>
|
| 95 | <servlet-class>
|
| 96 | org.apache.catalina.servlets.DefaultServlet
|
| 97 | </servlet-class>
|
| 98 | <init-param>
|
| 99 | <param-name>debug</param-name>
|
| 100 | <param-value>0</param-value>
|
| 101 | </init-param>
|
| 102 | <init-param>
|
| 103 | <param-name>listings</param-name>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 104 | <param-value>false</param-value>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 105 | </init-param>
|
| 106 | <load-on-startup>1</load-on-startup>
|
| 107 | </servlet>
|
| 108 |
|
| 109 | ...
|
| 110 |
|
| 111 | <servlet-mapping>
|
| 112 | <servlet-name>default</servlet-name>
|
| 113 | <url-pattern>/</url-pattern>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 114 | </servlet-mapping></code></pre></div>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 115 |
|
| 116 | So by default, the default servlet is loaded at webapp startup and
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 117 | directory listings are disabled and debugging is turned off.
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 118 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="change"><strong>What can I change?</strong></a></font></td></tr><tr><td><blockquote>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 119 | <p>
|
| 120 | The DefaultServlet allows the following initParamters:
|
| 121 | </p>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 122 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 123 | <table border="1" cellpadding="5"><tr><th width="15%" bgcolor="#023264"><font color="#ffffff">Property</font></th><th width="85%" bgcolor="#023264"><font color="#ffffff">Description</font></th></tr><tr><td align="left" valign="center"><code class="propertyName">debug</code></td><td align="left" valign="center">
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 124 | Debugging level. It is not very useful unless you are a tomcat
|
| 125 | developer. As
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 126 | of this writing, useful values are 0, 1, 11, 1000. [0]
|
| 127 | </td></tr><tr><td align="left" valign="center"><code class="propertyName">listings</code></td><td align="left" valign="center">
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 128 | If no welcome file is present, can a directory listing be
|
| 129 | shown?
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 130 | value may be <b>true</b> or <b>false</b> [false]
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 131 | <br>
|
| 132 | Welcome files are part of the servlet api.
|
| 133 | <br>
|
| 134 | <b>WARNING:</b> Listings of directories containing many entries are
|
| 135 | expensive. Multiple requests for large directory listings can consume
|
| 136 | significant proportions of server resources.
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 137 | </td></tr><tr><td align="left" valign="center"><code class="propertyName">readmeFile</code></td><td align="left" valign="center">
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 138 | If a directory listing is presented, a readme file may also
|
| 139 | be presented with the listing. This file is inserted as is
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 140 | so it may contain HTML.
|
| 141 | </td></tr><tr><td align="left" valign="center"><code class="propertyName">globalXsltFile</code></td><td align="left" valign="center">
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 142 | If you wish to customize your directory listing, you
|
Hongqing Liu | 7189829 | 2014-10-15 13:31:32 +0800 | [diff] [blame] | 143 | can use an XSL transformation. This value is a relative file name (to
|
| 144 | either $CATALINA_BASE/conf/ or $CATALINA_HOME/conf/) which will be used
|
| 145 | for all directory listings. This can be overridden per context and/or
|
| 146 | per directory. See <strong>contextXsltFile</strong> and
|
| 147 | <strong>localXsltFile</strong> below. The format of the xml is shown
|
| 148 | below.
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 149 | </td></tr><tr><td align="left" valign="center"><code class="propertyName">contextXsltFile</code></td><td align="left" valign="center">
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 150 | You may also customize your directory listing by context by
|
Hongqing Liu | 7189829 | 2014-10-15 13:31:32 +0800 | [diff] [blame] | 151 | configuring <code>contextXsltFile</code>. This must be a context
|
| 152 | relative path (e.g.: <code>/path/to/context.xslt</code>) to a file with
|
| 153 | a <code>.xsl</code> or <code>.xslt</code> extension. This overrides
|
| 154 | <code>globalXsltFile</code>. If this value is present but a file does
|
| 155 | not exist, then <code>globalXsltFile</code> will be used. If
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 156 | <code>globalXsltFile</code> does not exist, then the default
|
| 157 | directory listing will be shown.
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 158 | </td></tr><tr><td align="left" valign="center"><code class="propertyName">localXsltFile</code></td><td align="left" valign="center">
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 159 | You may also customize your directory listing by directory by
|
Hongqing Liu | 7189829 | 2014-10-15 13:31:32 +0800 | [diff] [blame] | 160 | configuring <code>localXsltFile</code>. This must be a file in the
|
| 161 | directory where the listing will take place to with a
|
| 162 | <code>.xsl</code> or <code>.xslt</code> extension. This overrides
|
| 163 | <code>globalXsltFile</code> and <code>contextXsltFile</code>. If this
|
| 164 | value is present but a file does not exist, then
|
| 165 | <code>contextXsltFile</code> will be used. If
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 166 | <code>contextXsltFile</code> does not exist, then
|
| 167 | <code>globalXsltFile</code> will be used. If
|
| 168 | <code>globalXsltFile</code> does not exist, then the default
|
| 169 | directory listing will be shown.
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 170 | </td></tr><tr><td align="left" valign="center"><code class="propertyName">input</code></td><td align="left" valign="center">
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 171 | Input buffer size (in bytes) when reading
|
| 172 | resources to be served. [2048]
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 173 | </td></tr><tr><td align="left" valign="center"><code class="propertyName">output</code></td><td align="left" valign="center">
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 174 | Output buffer size (in bytes) when writing
|
| 175 | resources to be served. [2048]
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 176 | </td></tr><tr><td align="left" valign="center"><code class="propertyName">readonly</code></td><td align="left" valign="center">
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 177 | Is this context "read only", so HTTP commands like PUT and
|
| 178 | DELETE are rejected? [true]
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 179 | </td></tr><tr><td align="left" valign="center"><code class="propertyName">fileEncoding</code></td><td align="left" valign="center">
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 180 | File encoding to be used when reading static resources.
|
| 181 | [platform default]
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 182 | </td></tr><tr><td align="left" valign="center"><code class="propertyName">sendfileSize</code></td><td align="left" valign="center">
|
| 183 | If the connector used supports sendfile, this represents the minimal
|
| 184 | file size in KB for which sendfile will be used. Use a negative value
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 185 | to always disable sendfile. [48]
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 186 | </td></tr><tr><td align="left" valign="center"><code class="propertyName">useAcceptRanges</code></td><td align="left" valign="center">
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 187 | If true, the Accept-Ranges header will be set when appropriate for the
|
| 188 | response. [true]
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 189 | </td></tr><tr><td align="left" valign="center"><code class="propertyName">showServerInfo</code></td><td align="left" valign="center">
|
| 190 | Should server information be presented in the response sent to clients
|
| 191 | when directory listing is enabled. [true]
|
| 192 | </td></tr></table>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 193 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="dir"><strong>How do I customize directory listings?</strong></a></font></td></tr><tr><td><blockquote>
|
| 194 | <p>You can override DefaultServlet with you own implementation and use that
|
| 195 | in your web.xml declaration. If you
|
| 196 | can understand what was just said, we will assume you can read the code
|
| 197 | to DefaultServlet servlet and make the appropriate adjustments. (If not,
|
| 198 | then that method isn't for you)
|
| 199 | </p>
|
| 200 | <p>
|
| 201 | You can use either <code>localXsltFile</code> or
|
| 202 | <code>globalXsltFile</code> and DefaultServlet will create
|
| 203 | an xml document and run it through an xsl transformation based
|
| 204 | on the values provided in <code>localXsltFile</code> and
|
| 205 | <code>globalXsltFile</code>. <code>localXsltFile</code> is first
|
| 206 | checked, followed by <code>globalXsltFile</code>, then default
|
| 207 | behaviors takes place.
|
| 208 | </p>
|
| 209 |
|
| 210 | <p>
|
| 211 | Format:
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 212 | </p>
|
| 213 | <div class="codeBox"><pre><code> <listing>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 214 | <entries>
|
| 215 | <entry type='file|dir' urlPath='aPath' size='###' date='gmt date'>
|
| 216 | fileName1
|
| 217 | </entry>
|
| 218 | <entry type='file|dir' urlPath='aPath' size='###' date='gmt date'>
|
| 219 | fileName2
|
| 220 | </entry>
|
| 221 | ...
|
| 222 | </entries>
|
| 223 | <readme></readme>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 224 | </listing></code></pre></div>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 225 | <ul>
|
| 226 | <li>size will be missing if <code>type='dir'</code></li>
|
| 227 | <li>Readme is a CDATA entry</li>
|
| 228 | </ul>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 229 |
|
| 230 | <p>
|
| 231 | The following is a sample xsl file which mimics the default tomcat behavior:
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 232 | </p>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 233 | <div class="codeBox"><pre><code><?xml version="1.0" encoding="UTF-8"?>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 234 |
|
| 235 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 236 | version="3.0">
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 237 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 238 | <xsl:output method="html" html-version="5.0"
|
| 239 | encoding="UTF-8" indent="no"
|
| 240 | doctype-system="about:legacy-compat"/>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 241 |
|
| 242 | <xsl:template match="listing">
|
| 243 | <html>
|
| 244 | <head>
|
| 245 | <title>
|
| 246 | Sample Directory Listing For
|
| 247 | <xsl:value-of select="@directory"/>
|
| 248 | </title>
|
| 249 | <style>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 250 | h1 {color : white;background-color : #0086b2;}
|
| 251 | h3 {color : white;background-color : #0086b2;}
|
| 252 | body {font-family : sans-serif,Arial,Tahoma;
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 253 | color : black;background-color : white;}
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 254 | b {color : white;background-color : #0086b2;}
|
| 255 | a {color : black;} HR{color : #0086b2;}
|
| 256 | table td { padding: 5px; }
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 257 | </style>
|
| 258 | </head>
|
| 259 | <body>
|
| 260 | <h1>Sample Directory Listing For
|
| 261 | <xsl:value-of select="@directory"/>
|
| 262 | </h1>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 263 | <hr style="height: 1px;" />
|
| 264 | <table style="width: 100%;">
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 265 | <tr>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 266 | <th style="text-align: left;">Filename</th>
|
| 267 | <th style="text-align: center;">Size</th>
|
| 268 | <th style="text-align: right;">Last Modified</th>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 269 | </tr>
|
| 270 | <xsl:apply-templates select="entries"/>
|
| 271 | </table>
|
| 272 | <xsl:apply-templates select="readme"/>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 273 | <hr style="height: 1px;" />
|
| 274 | <h3>Apache Tomcat/8.0</h3>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 275 | </body>
|
| 276 | </html>
|
| 277 | </xsl:template>
|
| 278 |
|
| 279 |
|
| 280 | <xsl:template match="entries">
|
| 281 | <xsl:apply-templates select="entry"/>
|
| 282 | </xsl:template>
|
| 283 |
|
| 284 | <xsl:template match="readme">
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 285 | <hr style="height: 1px;" />
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 286 | <pre><xsl:apply-templates/></pre>
|
| 287 | </xsl:template>
|
| 288 |
|
| 289 | <xsl:template match="entry">
|
| 290 | <tr>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 291 | <td style="text-align: left;">
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 292 | <xsl:variable name="urlPath" select="@urlPath"/>
|
| 293 | <a href="{$urlPath}">
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 294 | <pre><xsl:apply-templates/></pre>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 295 | </a>
|
| 296 | </td>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 297 | <td style="text-align: right;">
|
| 298 | <pre><xsl:value-of select="@size"/></pre>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 299 | </td>
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 300 | <td style="text-align: right;">
|
| 301 | <pre><xsl:value-of select="@date"/></pre>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 302 | </td>
|
| 303 | </tr>
|
| 304 | </xsl:template>
|
| 305 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 306 | </xsl:stylesheet></code></pre></div>
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 307 |
|
| 308 | </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="secure"><strong>How do I secure directory listings?</strong></a></font></td></tr><tr><td><blockquote>
|
| 309 | Use web.xml in each individual webapp. See the security section of the
|
| 310 | Servlet specification.
|
| 311 |
|
刘洪青 | 6266f99 | 2017-05-15 21:21:03 +0800 | [diff] [blame^] | 312 | </blockquote></td></tr></table></td></tr><tr class="noPrint"><td width="20%" valign="top" nowrap class="noPrint"></td><td width="80%" valign="top" align="left"><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="comments_section" id="comments_section"><strong>Comments</strong></a></font></td></tr><tr><td><blockquote><p class="notice"><strong>Notice: </strong>This comments section collects your suggestions
|
| 313 | on improving documentation for Apache Tomcat.<br><br>
|
| 314 | If you have trouble and need help, read
|
| 315 | <a href="http://tomcat.apache.org/findhelp.html">Find Help</a> page
|
| 316 | and ask your question on the tomcat-users
|
| 317 | <a href="http://tomcat.apache.org/lists.html">mailing list</a>.
|
| 318 | Do not ask such questions here. This is not a Q&A section.<br><br>
|
| 319 | The Apache Comments System is explained <a href="./comments.html">here</a>.
|
| 320 | Comments may be removed by our moderators if they are either
|
| 321 | implemented or considered invalid/off-topic.</p><script type="text/javascript"><!--//--><![CDATA[//><!--
|
| 322 | var comments_shortname = 'tomcat';
|
| 323 | var comments_identifier = 'http://tomcat.apache.org/tomcat-7.0-doc/default-servlet.html';
|
| 324 | (function(w, d) {
|
| 325 | if (w.location.hostname.toLowerCase() == "tomcat.apache.org") {
|
| 326 | d.write('<div id="comments_thread"><\/div>');
|
| 327 | var s = d.createElement('script');
|
| 328 | s.type = 'text/javascript';
|
| 329 | s.async = true;
|
| 330 | s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
|
| 331 | (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
|
| 332 | }
|
| 333 | else {
|
| 334 | d.write('<div id="comments_thread"><strong>Comments are disabled for this page at the moment.<\/strong><\/div>');
|
| 335 | }
|
| 336 | })(window, document);
|
| 337 | //--><!]]></script></blockquote></td></tr></table></td></tr><!--FOOTER SEPARATOR--><tr><td colspan="2"><hr noshade size="1"></td></tr><!--PAGE FOOTER--><tr><td colspan="2"><div align="center"><font color="#525D76" size="-1"><em>
|
| 338 | Copyright © 1999-2017, Apache Software Foundation
|
Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 339 | </em></font></div></td></tr></table></body></html> |