Tomcat的web.XML的简单问题,困惑了我一个晚上.求教各位.
我今天刚开始学习JSP的.按照教程上的,在webapps下新建了myapp,目录结构:
myapp
----WEB-INF
----web.XML
----classes
----test
----Test.class
web.XML中的内容如下:
<?xml version="1.0" encoding="gb2312"?>
<web-app>
<display-name>My Web Application</display-name>
<description>
A application for test.
</description>
<servlet>
<servlet-name>Test</servlet-name>
<servlet-class>test.Test</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Test</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>
</web-app>
但是访问http://localhost:8080/myapp/test的时候会提示"The requested resource (/myapp/test) is not available."
但是我把web.XML这个文件放在Tomcat目录下的conf文件夹中,就可以访问成功.是不是我的映射错了呢?请教各位,麻烦大家帮帮忙.先谢了:)
------解决方案--------------------XML code
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" 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">
<display-name >My Web Application </display-name >
<description >
A application for test.
</description >
<servlet >
<servlet-name >Test </servlet-name >
<servlet-class >test.Test </servlet-class >
</servlet >
<servlet-mapping >
<servlet-name >Test </servlet-name >
<url-pattern >/test </url-pattern >
</servlet-mapping >
</web-app>
有这么简单的web.xml吗?
加一些头上去吧