tomcat 设置项目 密码登陆

发布时间:2020-07-23 00:56:32 作者:wyy962653920
来源:网络 阅读:1611

设置 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 设置项目 密码登陆


推荐阅读:
  1. 排查tomcat服务器启动,项目无法运行故障
  2. 利用Nginx反向代理Tomcat 多节点

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

tomcat 安全认证 omc

上一篇:解决weebly无法载入的问题

下一篇:ELK 实验(一) 产品简介

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》