热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Tomcat7/8开启WebDAV的支持

WebDAV是一种超文本传输协议,Tomcat默认是支持WebDAV的,且默认为禁用状态。更多详细信息,请参考:https:

WebDAV是一种超文本传输协议,Tomcat默认是支持WebDAV的,且默认为禁用状态。

更多详细信息,请参考:

https://zh.wikipedia.org/wiki/WebDAV

http://www.webdav.org/

开启步骤如下:

1、在Tomcat的webapps目录下新建webdav文件夹,并在此文件夹下新建WEB-INF\web.xml文件

完整的文件目录为:C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\webdav\WEB-INF\web.xml

配置Servlet,添加如下节点:

<servlet><servlet-name>webdavservlet-name><servlet-class>org.apache.catalina.servlets.WebdavServletservlet-class><init-param><param-name>debugparam-name><param-value>0param-value>init-param><init-param><param-name>listingsparam-name><param-value>trueparam-value>init-param><init-param><param-name>readonlyparam-name><param-value>falseparam-value>init-param>servlet><servlet-mapping><servlet-name>webdavservlet-name><url-pattern>/*url-pattern>servlet-mapping>

配置权限&#xff0c;添加如下节点&#xff1a;

  <security-constraint><web-resource-collection><web-resource-name>webdavweb-resource-name><url-pattern>/*url-pattern><http-method>PROPFINDhttp-method><http-method>PROPPATCHhttp-method><http-method>COPYhttp-method><http-method>MOVEhttp-method><http-method>LOCKhttp-method><http-method>UNLOCKhttp-method>web-resource-collection><auth-constraint><role-name>*role-name>auth-constraint>security-constraint><login-config><auth-method>BASICauth-method><realm-name>webdavrealm-name>login-config><security-role><description>WebDAV Userdescription><role-name>webdavrole-name>security-role>

提示&#xff1a;为自定义权限名称。

根据上面权限名称&#xff0c;在Tomcat账号体系中增加账号密码&#xff0c;配置如下&#xff1a;

打开C:\Program Files\Apache Software Foundation\Tomcat 7.0\conf\tomcat-users.xml

<role rolename&#61;"webdav"/><user username&#61;"root" password&#61;"root" roles&#61;"webdav"/>

提示&#xff1a;权限名称必须和web.xml文件配置的一一对应。

完整的web.xml文件如下&#xff1a;

xml version&#61;"1.0" encoding&#61;"UTF-8"?>
<web-app xmlns:xsi&#61;"http://www.w3.org/2001/XMLSchema-instance"xmlns&#61;"http://java.sun.com/xml/ns/javaee"xsi:schemaLocation&#61;"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"id&#61;"WebApp_ID" version&#61;"3.0"><display-name>webdavdisplay-name><welcome-file-list><welcome-file>index.htmlwelcome-file><welcome-file>index.htmwelcome-file><welcome-file>index.jspwelcome-file><welcome-file>default.htmlwelcome-file><welcome-file>default.htmwelcome-file><welcome-file>default.jspwelcome-file>welcome-file-list><servlet><servlet-name>webdavservlet-name><servlet-class>org.apache.catalina.servlets.WebdavServletservlet-class><init-param><param-name>debugparam-name><param-value>0param-value>init-param><init-param><param-name>listingsparam-name><param-value>trueparam-value>init-param><init-param><param-name>readonlyparam-name><param-value>falseparam-value>init-param>servlet><servlet-mapping><servlet-name>webdavservlet-name><url-pattern>/*url-pattern>servlet-mapping><security-constraint><web-resource-collection><web-resource-name>webdavweb-resource-name><url-pattern>/*url-pattern><http-method>PROPFINDhttp-method><http-method>PROPPATCHhttp-method><http-method>COPYhttp-method><http-method>MOVEhttp-method><http-method>LOCKhttp-method><http-method>UNLOCKhttp-method>web-resource-collection><auth-constraint><role-name>*role-name>auth-constraint>security-constraint><login-config><auth-method>BASICauth-method><realm-name>webdavrealm-name>login-config><security-role><description>WebDAV Userdescription><role-name>webdavrole-name>security-role>
web-app>

整个站点文件&#xff1a;链接&#xff1a;http://pan.baidu.com/s/1mit5KO4 密码&#xff1a;ykkj

配置完成后&#xff0c;重启Tomcat&#xff0c;然后访问站点&#xff0c;出现如下样式证明已经成功&#xff1a;

 

参考&#xff1a;

https://www.mulesoft.com/cn/tcat/tomcat-webdav&#xff08;Tomcat配置&#xff09;

https://my.oschina.net/liangrockman/blog/39462&#xff08;Tomcat配置&#xff09;

http://www.yiibai.com/article/enable-webdav-in-apache-server-2-2-x-windows.html&#xff08;Apache的配置&#xff09;

&#61;&#61;>如有问题&#xff0c;请联系我&#xff1a;easonjim#163.com&#xff0c;或者下方发表评论。<&#61;&#61;


推荐阅读
author-avatar
骷髅怪天堂_821
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有