<web-app>
  <servlet>
    ...
    <init-param>
      <param-name>listings</param-name>
      <param-value>false</param-value>
    </init-param>
    ...
  </servlet>
  ...
  <security-constraint>
    <display-name>Restrict access to JSP pages</display-name>
    <web-resource-collection>
      <web-resource-name>
        Restrict access to JSP pages
      </web-resource-name>
      <url-pattern>/css/*</url-pattern>
      <url-pattern>/image/*</url-pattern>
      <url-pattern>/js/*</url-pattern>
      <url-pattern>/jsp/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <description>
With no roles defined, no access granted
      </description>
    </auth-constraint>
  </security-constraint>
  ...
</web-app>给你一个例子,试试看看。

解决方案 »

  1.   

    请问是修改WEB-INF目录下的web.xml文件吗?
    麻烦说详细一点修改哪几个参数
    谢谢!
      

  2.   

    web.xml文件。把sagittarius1979(射手爱狮子) 给你的代码粘到文件就可以了。但是不要粘错了
      

  3.   

    关键的地方是将你的目录列印功能关闭,web.xml中有关目录列印的参数设置是listing.也就是下面的配置中的初始化参数listings,你把它的默认值改为false就可以了。<servlet>
        ...
        <init-param>
          <param-name>listings</param-name>
          <param-value>false</param-value>
        </init-param>
        ...
      </servlet>
      

  4.   

    谢谢

      <!--   input               Input buffer size (in bytes) when reading      -->
      <!--                       resources to be served.  [2048]                -->
      <!--                                                                      -->
      <!--   listings            Should directory listings be produced if there -->
      <!--                       is no welcome file in this directory?  [true]  -->
      <!--                                                                      -->
      <!--   output              Output buffer size (in bytes) when writing     -->
      <!--                       resources to be served.  [2048]                -->”

    只怪自己没仔细去看这些东西。