为什么Tomcat的webapps目录下新建的目录不能访问html文件?
2009-05-02 17:26
417 查看
为什么Tomcat的webapps目录下新建的目录不能访问html文件?
在Tomcat安装目录中,webapps默认为部署网站用的目录。webapps/ROOT是网站的根目录,其它目录都是网站的子目录,如webapps\jsp-examples目录。但是,当我们新建一个子目录时,却并不能在浏览器里正常访问。就连HTML文件也访问不了。为什么会出现这种情况呢?
原来,在Tomcat中,每一个webapps下的子目录都被认为是一个JSP站点。因此,该子目录必需要有JSP站点的必要结构才行。也就是,在创建的子目录下,必需有WEB_INF目录以及WEB_INF下的web.xml文件。WEB_INF目录以及其下的web.xml文件,是JSP用来配置站点用的。
以test子目录为例,以下就是正确配置Tomcat子目录的目录结构:
webapps\
┝ ROOT\
│ │
│ ┕ …
┕ test\
│
┝ index.html
│
┕ WEB_INFO\
│
┕ web.xml
空的web.xml文件内容如下:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Copyright 2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
</web-app>
在Tomcat安装目录中,webapps默认为部署网站用的目录。webapps/ROOT是网站的根目录,其它目录都是网站的子目录,如webapps\jsp-examples目录。但是,当我们新建一个子目录时,却并不能在浏览器里正常访问。就连HTML文件也访问不了。为什么会出现这种情况呢?
原来,在Tomcat中,每一个webapps下的子目录都被认为是一个JSP站点。因此,该子目录必需要有JSP站点的必要结构才行。也就是,在创建的子目录下,必需有WEB_INF目录以及WEB_INF下的web.xml文件。WEB_INF目录以及其下的web.xml文件,是JSP用来配置站点用的。
以test子目录为例,以下就是正确配置Tomcat子目录的目录结构:
webapps\
┝ ROOT\
│ │
│ ┕ …
┕ test\
│
┝ index.html
│
┕ WEB_INFO\
│
┕ web.xml
空的web.xml文件内容如下:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Copyright 2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
</web-app>
相关文章推荐
- 为什么Tomcat的webapps目录下新建的目录不能访问html文件?
- 为什么Tomcat的webapps目录下新建的目录不能访问html文件?
- 为什么Tomcat的webapps目录下新建的目录不能访问html文件?
- Tomcat的webapps目录下新建的目录不能访问
- eclipse中把web项目部署在tomcat中,可以使用浏览器访问,但是无法在tomcat目录中的webapps中找到?
- 把war包放到Tomcat安装目录下,不能直接访问的解决方案
- tomcat虚拟路径——webapps目录外部静态资源访问
- tomcat配置多域名访问非webapps下面多工程目录(类似IIS主机头)
- tomcat的webapps目录下放更新后的项目就访问不了
- eclipse新建web项目,运行后在tomcat安装目录下webapps中没有该项目
- tomcat域名能访问。ip地址不能访问:服务器防止攻击
- Ubuntu中的tomcat能启动却不能用localhost:8080访问
- 将Eclipse项目自动部署到Tomcat的webapps目录下
- 不能从其他机器访问RHEL5.5上的tomcat6
- 为什么子类中不能访问另一个包中父类中的protected方法?
- CentOS7上解决tomcat不能被外部浏览访问
- Windows 10下安装Tomcat,文件目录共享访问
- Tomcat项目部署成功,页面访问404,Work目录权限问题
- 若允许Tomcat所有域访问,将clientaccesspolicy.xml和crossdomain.xml加入%TOMCAT_HOME%\webapps\ROOT 目录下即可
- 解决通过局域网ip不能访问Tomcat上发布的项目