<?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>
<!-- JSPC servlet mappings start -->
<servlet>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<servlet-class>org.apache.jsp.index_jsp</servlet-class>
</servlet>
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<url-pattern>/index.jsp</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/servlet/helloworld</url-pattern>
</servlet-mapping>
<!-- JSPC servlet mappings end -->
</web-app>
把HelloWorld.class放到webapps\myWeb\WEB-INF\classes下,运行时显示
HTTP Status 404 - /servlet/HelloWorld
--------------------------------------------------------------------------------
type Status report
message /servlet/HelloWorld
description The requested resource (/servlet/HelloWorld) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/5.5.16
----------------解决方案--------------------------------------------------------
启动Tomcat
打开 IE 输入 http://localhost:8080/项目名/servlet/HelloWorld
----------------解决方案--------------------------------------------------------
我就是这么作的,结果就是上面显示的问题,文件找不到?
----------------解决方案--------------------------------------------------------
>/servlet/helloworld
这个是路径吧
[此贴子已经被作者于2006-11-15 22:27:22编辑过]
----------------解决方案--------------------------------------------------------
这里
<url-pattern>/servlet/helloworld</url-pattern>
helloworld是小写的。
所以地址也要小写:http://localhost:8080/myWeb/servlet/helloworld
用Tomcat时要小心,大小写是敏感的,对于地址也一样。
----------------解决方案--------------------------------------------------------
谢谢楼上的,我就是没注意大小写,真是太马虎了,也多谢各位的支持!
----------------解决方案--------------------------------------------------------