zhyiwww
          用平實的筆,記錄編程路上的點點滴滴………
          posts - 536,comments - 394,trackbacks - 0
             
          tomcat下basic授權的訪問配置
          【1】把下面的代碼放到你在自己項目的<web-app>下面

          <security-constraint>
                  <web-resource-collection>
                      <web-resource-name>Entire Application</web-resource-name>
                      <url-pattern>/*</url-pattern>
                   </web-resource-collection>
                  <!-- NOTE: This role is not present in the default users file -->
                  <auth-constraint>
                      <role-name>user</role-name>
                  </auth-constraint>

              </security-constraint>

              <!-- Define the Login Configuration for this Application -->
              <login-config>
                  <auth-method>BASIC</auth-method>
                  <realm-name>TEST ACCESS CONTROL</realm-name>
              </login-config>

          【2】在tomcat-user.xml里面,添加如下代碼
          <tomcat-users>
            <role rolename="user"/>
            <user username="xyz" password="xyz" roles="user"/>
          </tomcat-users>
          【3】重啟tomcat就可以了





          |----------------------------------------------------------------------------------------|
                                     版權聲明  版權所有 @zhyiwww
                      引用請注明來源 http://www.aygfsteel.com/zhyiwww   
          |----------------------------------------------------------------------------------------|
          posted on 2010-09-17 09:55 zhyiwww 閱讀(875) 評論(0)  編輯  收藏 所屬分類: j2ee
          主站蜘蛛池模板: 屏东县| 石台县| 榕江县| 桦川县| 丰镇市| 天全县| 清苑县| 封丘县| 辽源市| 普宁市| 宁乡县| 霞浦县| 荆门市| 高青县| 孟津县| 金乡县| 松阳县| 闽清县| 芜湖市| 辽宁省| 长阳| 八宿县| 江口县| 大理市| 临泉县| 屏边| 义马市| 乌什县| 咸丰县| 喀喇| 宜丰县| 民勤县| 开阳县| 偃师市| 泾源县| 台州市| 祁门县| 卢氏县| 永新县| 泰宁县| 宁都县|