阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Tomcat 设置项目 密码登陆

130次阅读
没有评论

共计 2212 个字符,预计需要花费 6 分钟才能阅读完成。

Tomcat 设置项目 密码登陆

设置 tomcat-user.xml

<?xml version=’1.0′ encoding=’utf-8′?>
<tomcat-users>
    <role rolename=”yy_role”/>
    <user username=”yyadmin” password=”yyadmin” roles=”yy_role”/>
</tomcat-users>

自己的工程下设置 web.xml

<?xml version=”1.0″ encoding=”UTF-8″?> 
<web-app xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns=”http://java.sun.com/xml/ns/javaee” xmlns:web=”http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd” xsi:schemaLocation=”http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd” id=”WebApp_ID” version=”2.5″> 
  <display-name>app</display-name> 
  <welcome-file-list> 
    <welcome-file>index.html</welcome-file> 
    <welcome-file>index.htm</welcome-file> 
    <welcome-file>index.jsp</welcome-file> 
    <welcome-file>default.html</welcome-file> 
    <welcome-file>default.htm</welcome-file> 
    <welcome-file>default.jsp</welcome-file> 
  </welcome-file-list> 
     
<security-constraint>
      <web-resource-collection>
        <web-resource-name>force login</web-resource-name>
        <!– Define the context-relative URL(s) to be protected –>
        <url-pattern>/*</url-pattern>
        <!– If you list http methods, only those methods are protected –>
      </web-resource-collection>
      <auth-constraint>
        <!– Anyone with one of the listed roles may access this area –>
        <role-name>yy_role</role-name>
      </auth-constraint>
    </security-constraint>
    <login-config>   
    <auth-method>BASIC</auth-method> 
    <realm-name>force login</realm-name>
    </login-config>
    <!– Security roles referenced by this web application –>
    <security-role>
      <role-name>yy_role</role-name>
    </security-role> 
   
</web-app>

测试:要加密的项目

Tomcat 设置项目 密码登陆

测试:确认不影响网站其他项目

Tomcat 设置项目 密码登陆

更多 Tomcat 相关教程见以下内容

CentOS 6.6 下安装配置 Tomcat 环境  http://www.linuxidc.com/Linux/2015-08/122234.htm

RedHat Linux 5.5 安装 JDK+Tomcat 并部署 Java 项目  http://www.linuxidc.com/Linux/2015-02/113528.htm 

Tomcat 权威指南(第二版)(中英高清 PDF 版 + 带书签)  http://www.linuxidc.com/Linux/2015-02/113062.htm 

Tomcat 安全配置与性能优化 http://www.linuxidc.com/Linux/2015-02/113060.htm 

Linux 下使用 Xshell 查看 Tomcat 实时日志中文乱码解决方案 http://www.linuxidc.com/Linux/2015-01/112395.htm 

CentOS 64-bit 下安装 JDK 和 Tomcat 并设置 Tomcat 开机启动操作步骤 http://www.linuxidc.com/Linux/2015-01/111485.htm 

CentOS 6.5 下安装 Tomcat  http://www.linuxidc.com/Linux/2015-01/111415.htm 

Tomcat 的详细介绍:请点这里
Tomcat 的下载地址:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-03/129484.htm

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-21发表,共计2212字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中