tomcat配置http digest认证
2016-05-12 14:46
791 查看
具体步骤如下:
1、在tomcat服务器下的webapps下新建一个digesttest的文件夹,在该文件夹下新建一个test的文件夹,进入test文件夹,在该文件夹下新建一个index.jsp。(jsp的内容可以随便选择,比如说是一个随意的网页的代码)
2、在digesttest新建一个WEB-INF的文件夹,在该文件夹下新建一个web.xml文件。内容如下所示:
<?xml version="1.0" encoding="UTF-8"?>
< web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<security-constraint>
<web-resource-collection>
<web-resource-name>
My App
</web-resource-name>
<url-pattern>/test/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>tomcat</role-name> <!-- tomcat中配置的用户角色-->
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>DIGEST</auth-method> <!-- DIGEST here -->
<realm-name>My Realm</realm-name>
</login-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
< /web-app>
3、在tomcat\conf下搜索tomcat-users.xml文件,打开编辑,添加一个用户,密码和角色。用户名为:test;密码:test;角色可以是默认的tomcat或者自己定义的。
4、重启tomcat服务器,在地址栏如入http://localhost:8080/digesttest/test/index.jsp。就会弹出来一个对话框,在其中输入你在tomcat-users.xml下新设置的用户名和密码(test,test)。就会跳转到该页面。
1、在tomcat服务器下的webapps下新建一个digesttest的文件夹,在该文件夹下新建一个test的文件夹,进入test文件夹,在该文件夹下新建一个index.jsp。(jsp的内容可以随便选择,比如说是一个随意的网页的代码)
2、在digesttest新建一个WEB-INF的文件夹,在该文件夹下新建一个web.xml文件。内容如下所示:
<?xml version="1.0" encoding="UTF-8"?>
< web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<security-constraint>
<web-resource-collection>
<web-resource-name>
My App
</web-resource-name>
<url-pattern>/test/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>tomcat</role-name> <!-- tomcat中配置的用户角色-->
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>DIGEST</auth-method> <!-- DIGEST here -->
<realm-name>My Realm</realm-name>
</login-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
< /web-app>
3、在tomcat\conf下搜索tomcat-users.xml文件,打开编辑,添加一个用户,密码和角色。用户名为:test;密码:test;角色可以是默认的tomcat或者自己定义的。
4、重启tomcat服务器,在地址栏如入http://localhost:8080/digesttest/test/index.jsp。就会弹出来一个对话框,在其中输入你在tomcat-users.xml下新设置的用户名和密码(test,test)。就会跳转到该页面。
相关文章推荐
- Swift HTTP GET请求例子
- 基于感知器模型的线性神经网络
- Http响应和HttpServletResponse对应设置方法
- 机房网络规划
- 【UNIX网络编程】TCP客户/服务器程序示例
- 神经网络压缩:Deep Compression
- android 开发中找不到org.apache.http包以及相应的类
- HttpServlet中的service和doGet的区别
- Http请求和HttpServletRequest中获得对应参数的方法
- 网络流SAP
- Http之Get/Post请求区别
- php与Ajax(二)—XMLHttpRequest对象的方法与属性
- 网络流二十四题之六 —— 最长不下降子序列问题(ALIS)
- 如何在 在SharePoint 2013/2010 解决方案中添加 ashx (HttpHandler)
- Servlet 处理HTTP请求
- HTTP 2.0
- Swift网络请求,数据模型,图片缓存,自动布局,上拉刷新下拉加载
- Http Post远程调用
- HTTP、HTTPS
- 以太网基础知识0(UDP和TCP有什么区别)