屏蔽tomcat的目录列表功能

屏蔽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><iframe name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-2141342037947367&amp;amp;dt=1111582269187&amp;amp;lmt=1111582268&amp;amp;prev_fmts=468x60_pas_abgnc&amp;amp;format=120x240_as&amp;amp;output=html&amp;amp;channel=8570654326&amp;amp;url=http%3A%2F%2Fwww.javaresearch.org%2Farticle%2Fshowarticle.jsp%3Fcolumn%3D556%26thread%3D1089&amp;amp;color_bg=FFFFFF&amp;amp;color_text=333333&amp;amp;color_link=000000&amp;amp;color_url=666666&amp;amp;color_border=CCCCCC&amp;amp;u_h=768&amp;amp;u_w=1024&amp;amp;u_ah=738&amp;amp;u_aw=1024&amp;amp;u_cd=32&amp;amp;u_tz=480&amp;amp;u_his=1&amp;amp;u_java=true&amp;amp;u_nplug=17&amp;amp;u_nmime=68" frameborder="0" width="120" scrolling="no" height="240" allowtransparency="65535"></iframe>
缺省情况下,如果你访问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>


你可能感兴趣的:(JavaScript,apache,tomcat,servlet,Google)