屏蔽tomcat的目录列表功能 |
cherami 原创 转自:java研究组织 |
<script language="javascript" type="text/javascript"> <![CDATA[showbanner(6,6,1);]]> </script><script type="text/javascript"> <![CDATA[google_ad_client ="pub-2141342037947367";google_ad_width = 120;google_ad_height =240;google_ad_format = "120x240_as";google_ad_channel="8570654326";google_color_border = "CCCCCC";google_color_bg ="FFFFFF";google_color_link = "000000";google_color_url ="666666";google_color_text = "333333";]]> </script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> <![CDATA[]]> </script> name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-2141342037947367&dt=1111582269187&lmt=1111582268&prev_fmts=468x60_pas_abgnc&format=120x240_as&output=html&channel=8570654326&url=http%3A%2F%2Fwww.javaresearch.org%2Farticle%2Fshowarticle.jsp%3Fcolumn%3D556%26thread%3D1089&color_bg=FFFFFF&color_text=333333&color_link=000000&color_url=666666&color_border=CCCCCC&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_his=1&u_java=true&u_nplug=17&u_nmime=68" frameborder="0" width="120" scrolling="no" height="240" allowtransparency="65535"> |
|
缺省情况下,如果你访问tomcat下的一个web应用,那么如果你输入的是一个目录名,而且该目录下没有一个可用的welcome文件,那么 tomcat会将该目录下的所有文件列出来,如果你想屏蔽这个缺省行为,那么可以修改conf/web.xml文件,将其中的:
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>
true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
修改为:
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>
false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>