WEB-INF用户是不能访问到的,现在我想自己设置个文件夹,让用户不能访问,该如何实现

解决方案 »

  1.   

    可以参考一下这个:http://topic.csdn.net/t/20040317/10/2852069.html
      

  2.   

    你如下设置就可以了  
       
      Tomcat_Homt\conf\tomcat-users.xml   文件内容如下,注意其中的employee和web.xml中的employee是对应的。  
       
      <?xml   version='1.0'   encoding='utf-8'?>  
      <tomcat-users>  
          <role   rolename="tomcat"/>  
          <role   rolename="employee"/>  
          <role   rolename="buyc"/>  
          <role   rolename="role1"/>  
          <role   rolename="manager"/>  
          <role   rolename="admin"/>  
          <user   username="buyc"   password="buyc"   roles="buyc,employee"/>  
      </tomcat-users>  
       
      你的Webapp下WEB-INF\web.xml内容  
       
      <?xml   version="1.0"   encoding="UTF-8"?>  
      <!DOCTYPE   web-app   PUBLIC   "-//Sun   Microsystems,   Inc.//DTD   Web   Application   2.3//EN"   "http://java.sun.com/dtd/web-app_2_3.dtd">  
      <web-app>  
      <description>  
                      ShiFang   Soft.   OA  
              </description>  
       
          <!--   Security   is   active   on   entire   directory   -->  
          <security-constraint>  
              <display-name>Tomcat   Server   Configuration   Security   Constraint</display-name>  
              <web-resource-collection>  
                  <web-resource-name>Protected   Area</web-resource-name>  
                  <!--   Define   the   context-relative   URL(s)   to   be   protected   -->  
                  <url-pattern>*.jsp</url-pattern>  
                  <url-pattern>*.do</url-pattern>  
                  <url-pattern>*.html</url-pattern>  
              </web-resource-collection>  
              <auth-constraint>  
                  <!--   Anyone   with   one   of   the   listed   roles   may   access   this   area   -->  
                  <role-name>employee</role-name>  
              </auth-constraint>  
          </security-constraint>  
       
          <!--   Login   configuration   uses   form-based   authentication   -->  
              <login-config>  
                      <auth-method>BASIC</auth-method>  
                      <realm-name>Authenticate   yourself</realm-name>  
              </login-config>  
       
       
          <!--   Security   roles   referenced   by   this   web   application   -->  
          <security-role>  
              <description>  
                  The   role   that   is   required   to   log   in   to   the   Administration   Application  
              </description>  
              <role-name>employee</role-name>  
          </security-role>  
       
      </web-app>