servlet启动问题

问题:
在apache-tomcat-7.0.14\webapps\ch02下可以正常运行,将ch02下面文件全部复制粘贴到
在F:\web\ch02下就出现404错误
server.xml 配置如下<Context path="/web" docBase="f:/web" debug="0" reloadable="true"/> 
浏览器输入:http://localhost:8080/ch02/helloworld
输出:Hello World 
浏览器输入:http://localhost:8080/web/ch02/helloworld
输出:
HTTP Status 404 - /web/ch02/helloworld

--------------------------------------------------------------------------------

type Status report

message /web/ch02/helloworld

description The requested resource (/web/ch02/helloworld) is not available.

其中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">
  <servlet>
  <servlet-name>HelloWorldServlet</servlet-name>
  <servlet-class>org.sunxin.web.ch02.servlet.HelloWorldServlet</servlet-class>
  </servlet>

  <servlet-mapping>
  <servlet-name>HelloWorldServlet</servlet-name>
  <url-pattern>/helloworld</url-pattern>
  </servlet-mapping>
  </web-app>
请问怎么回事啊,求大牛帮助。找了很多办法都不行。
回答:
server.xml 配置如下<Context path="/web" docBase="f:/web" debug="0" reloadable="true"/>  

配置文件错了
应该是
<Context path="/ch02" docBase="f:/web/ch02" debug="0" reloadable="true"/> 
浏览器输入:http://localhost:8080/ch02/helloworld

猜你喜欢

转载自zzxy001.iteye.com/blog/1267171