在server.xml中配置这个  
<!-- Use the LockOutRealm to prevent attempts to guess user passwords  
           via a brute-force attack -->  
      <Realm className="org.apache.catalina.realm.LockOutRealm">  
        <!-- This Realm uses the UserDatabase configured in the global JNDI  
             resources under the key "UserDatabase".  Any edits  
             that are performed against this UserDatabase are immediately  
             available for use by the Realm.  -->  
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"  
               resourceName="UserDatabase"/>  
      </Realm>  
  
  
<GlobalNamingResources>  
    <!-- Editable user database that can also be used by  
         UserDatabaseRealm to authenticate users  
    -->  
    <Resource name="UserDatabase" auth="Container"  
              type="org.apache.catalina.UserDatabase"  
              description="User database that can be updated and saved"  
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"  
              pathname="conf/tomcat-users.xml" />  
  </GlobalNamingResources>