description The requested resource 的问题
我在配置servlet的时候,出现一些问题!
我所用的环境是tomcat 1.4.31+windows XP sp2
首先在配置了service.xml 设置虚拟目录;
<Context path= "/test " docBase= "d:\myweb " debug= "0 "/>
然后在d:\myweb目录里面新建目录myweb,在里面建立WEB-INF,其中里面有classes文件,
在classes里面有HelloServlet.class文件,其中HelloServlet的内容为:
===============================================================
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloServlet extends HttpServlet
{
public void service(HttpServletRequest request,HttpServletResponse response) throws
ServletException,
IOException {
PrintWriter out=response.getWriter();
out.println( " <html> ");
out.println( " <font size=30 color=red> www.sohu.com </font> <br> ");
out.println( " <marquee> "+new java.util.Date()+ " </marquee> ");
out.println( " </html> ");
}
}
===============================================================
编译是没有问题的.
然后在myweb文件袋里面新建web.xml文件,内容如下:
===============================================================
<?xml version= "1.0 " encoding= "UTF-8 "?>
<web-app xmlns= "http://java.sun.com/xml/ns/j2ee " xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance " version= "2.4 " xsi:schemaLocation= "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">
<servlet>
<servlet-name> Anyname </servlet-name>
<servlet-class> HelloServlet </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> AnyName </servlet-name>
<url-pattern> /demo/Hello.html </url-pattern>
</web-app>
===============================================================
然后重新启动tomcat.在浏览器里面输入:http://localhost:8080/test/demo/hello.html后
显示HTTP Status 404
type Status report
message /test/demo/hello.html
description The requested resource (/jason/demo/hello.html) is not available.
===================================================================
我在浏览器输入http://localhost:8080 可以正常显示,这个表示tomcat没有问题吧!
在浏览器里面输入http://localhost:8080/test可以正常显示该目录的资源,(在该目录我存放了一个testpage.html文件,可以正常显示出来)这样应该虚拟目录没有问题吧!
请各位帮我看一看是什么问题,我重新试过几次了,包括重启,重新
启动tomcat,问题依然存在,请大家帮帮忙!谢谢...
------解决方案--------------------http://localhost:8080/test/demo/hello 试试
再说SERVLET是请求才相应的,你怎么直接调用了