java环境,以及tomcat环境都正常
在webapps下自建jsp目录
jsp目录下有 WEB-INF ,同时编写了web.xml
可以访问jsp下的test.jsp现在弄了一个servlet
编译没有问题
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Test extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out=response.getWriter();
out.println("<html>;<body>;<h1>;This is a servlet test.</h1>;</body>;</html>;");
out.flush();
}
}
================分界线================
web.xml如下
<?xml version="1.0" encoding="ISO-8859-1"?>
<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>Test</servlet-name>
<servlet-class>Test</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Test</servlet-name>
<url-pattern>/Test</url-pattern>
</servlet-mapping>
<!-- JSPC servlet mappings end -->
</web-app>
=========分界=========
把Test.class放在classes目录下
重新启动tomcat以后,http://localhost:8080/jsp/Test
提示:
type Status reportmessage /jsp/Testdescription The requested resource (/jsp/Test) is not available.

解决方案 »

  1.   

    最好用一个包来装你的class
    在前面加上
    package test;
    重新编译,修改web.xml的<servlet-class>test.test</servlet-class>
      

  2.   

    另外修改了之后要记得重启TOMCAT才生效~~
      

  3.   

    最好用package,很多人都在问同样的问题
      

  4.   

    我把Test.class放在 root目录下的 web-inf/classes下
    然后修改了 web.xml 把
    <servlet>
    <servlet-name>Test</servlet-name>
    <servlet-class>Test</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Test</servlet-name>
    <url-pattern>/Test</url-pattern>
    </servlet-mapping>
    加入
    通过访问 http://localhost:8080/Test 可以正常访问!
    不过我的 http://localhost:8080/jsp/test.jsp都是可以正常访问的
    但是 http://localhost:8080/jsp/Test不可以修改web.xml都重新启动过tomcat
      

  5.   

    问题解决了
    把root下的web-inf都拷贝到jsp目录下
    就可以了