Servlet 出现404 not found 的问题
来源:互联网 发布:越南经济现状2017知乎 编辑:程序博客网 时间:2024/06/06 09:06
我在学习serlvet时出现了以下的情况:
HTTP Status 404 - /headfirst/SelectBeer.do
type Status report
message /headfirst/SelectBeer.do
description The requested resource is not available.
Apache Tomcat/8.0.3
404 not found就是找不到文件,路径出了问题。我是跟着headfirst那书做的,我的部署文件web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1"
metadata-complete="true">
<servlet>
<servlet-name>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>
</web-app>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1"
metadata-complete="true">
<servlet>
<servlet-name>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>
</web-app>
这里反复检查是没问题的。
我一开始在tomcat下项目的目录是这样的:/opt/apache-tomcat-8.0.3/webapps/headfirst/beerv1
后来发现问题就是在这里,因为headfirst有很多章节,所以我就间了一个headfirst文件夹来放这本书的demo,但是正是因为多了这一层导致找不到我的Servlet文件,因为<servlet-class>com.example.web.BeerSelect</servlet-class>是直接以webapps/headfirst作为了根目录。
我的解决方法:去除了headfirst这个文件夹,项目的路径变成:/opt/apache-tomcat-8.0.3/webapps/beerv1
这样就成功访问到这个servlet了。
0 0
- Servlet 出现404 not found 的问题
- iis发布后出现 .woff 404 (Not Found)的问题
- 解决网站出现GET .woff 404 (Not Found)的问题
- bootstrap解决图标显示不出来问题,出现GET .woff 404 (Not Found)的问题
- 启动WinMySQLAdmin出现-MyODBC- Not Found 的问题
- 解决 部分出现valid signing identity not found的问题
- 在ubuntu下出现declare:not found的问题
- 编译Apache出现的问题:configure: error: APR not found .
- 在ubuntu下出现declare:not found的问题
- ./configure 出现package was not found问题的解决办法
- 解决Windows版Git出现templates not found的问题
- 解决HEXO出现ERROR Deployer not found: git的问题
- Windows版Git出现templates not found的问题
- Eclipse调试时出现source not found的问题
- 安装git出现templates not found的问题
- Eclipse调试时出现source not found的问题
- 解决apt-get install blktrace时,出现source 404 not found的问题
- lnmp环境下ThinkPHP3.2出现404 Not Found的问题
- code forces 399A Pages
- 数据挖掘方法(4):多元回归
- python join字符连接函数的使用方法
- 使用Shader填充图形
- Heartbeat
- Servlet 出现404 not found 的问题
- 使用<s:action>访问action无法显示结果jsp的问题
- ACM-简单题之18岁生日——hdu1201
- nativeclient c++ ppapi opengles 初始化
- Intel Xeon Phi Coprocessor驱动程序MPSS的安装过程
- ZOJ 1942
- quartus II 过期怎么办?
- 通过一个简单的例子看服务端的启动过程以及客户端与服务端的连接过程(Netty 4.0.18)
- new一个对象的过程