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 閱讀(868) 評論(0)  編輯  收藏 所屬分類: j2ee
          主站蜘蛛池模板: 潞城市| 江山市| 英德市| 南康市| 泽州县| 禄丰县| 凤台县| 巢湖市| 肇源县| 延安市| 安顺市| 剑阁县| 临清市| 出国| 浠水县| 乐平市| 新乐市| 福清市| 阿瓦提县| 揭东县| 太谷县| 江油市| 九龙城区| 龙陵县| 望都县| 太仓市| 辉县市| 望城县| 南丹县| 龙陵县| 云林县| 滦平县| SHOW| 威宁| 夏河县| 梧州市| 灵宝市| 阜宁县| 兴仁县| 南康市| 曲麻莱县|