The DefaultServlet
of Tomcat is by default configured to not show directory listings. You need to open Tomcat's own /conf/web.xml
file (look in Tomcat installation folder), search the <servlet>
entry of the DefaultServlet
and then change its listings
initialization parameter from
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
to
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
Keep in mind that this affects all folders of your webapp. If you want to enable this for only an individual folder, you've got to write some Servlet
code yourself which does the job with help of the java.io.File
API in servlet side to collect the files and some bunch of HTML/CSS in JSP side to present it in a neat fashion.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…