我用的是eclipse3.0.1+tomcat5+lomboz3.0,我写了一个index.jsp和一个servlet:
我在jsp中使submit提交到servlet上去,可是我的页面刚打开就打不开。
不知道是不是配置有问题,代码如下:
jsp如下:
<!-- Copyright (c) 2002 by ObjectLearn. All Rights Reserved. -->
<html>
<head>
<title>FormGetExample</title>
</head>
<body background="#FFFFF">
    <form name="form" method="get" action="http://localhost:8080/servlet/FormGetExample1">
     <table width="261" height="30">
     <tr>
     <td width="109" height="10">姓名:</td>
     <td width="276" height="10">
     <input type="text" name="nickname">
     </td>
     </tr>
     <tr>
     <td width="109" height="8">密码:</td>
     <td width="276" height="4">
     <input type="password" name="pssword1" value="">
     </td>
     </tr>
     </table>
     <p align="center">
     <input type="submit" name="submit" value="确定">
     <input type="submit" name="submit" value="重来">
     </p>
    </form>
  </body>
</html>servlet如下:
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;public class FormGetExample1 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out .println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println("  <HEAD><TITLE>Servlet Get Example</TITLE></HEAD>");
out.println("  <BODY>");
out.print("<p>&nbsp;</p>");
out.print("<p><font size='+4'>"+"Servlet Get Example"+"</font></p>");
Enumeration Enumeration = request.getParameterNames();
while(Enumeration.hasMoreElements())
{
String key = (String)Enumeration.nextElement();
String value = request.getParameter(key);
out.print("<P>");
out.print(key+"="+value);
out.print("</P>");
}
out.println("  </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}
}
web.xml如下:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Copyright (c) 2002 by ObjectLearn. All Rights Reserved. -->
<web-app>
<servlet>
<servlet-name>FormGetExample1</servlet-name>
<display-name>FormGetExample1</display-name>
<description>FormGetExample1</description>
<servlet-class>FormGetExample1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FormGetExample1</servlet-name>
<url-pattern>FormGetExample1</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list> <error-page>
<error-code>404</error-code>
<location>/error.jsp</location>
</error-page></web-app>请高手指教,给高分。

解决方案 »

  1.   

    估计是URL的问题吧。。
    你项目名是什么??servlet???
    http://localhost:8080/项目名/FormGetExample1
      

  2.   

    项目名是FormGetExample,servlet名为FormGetExample1,运行的结果为如下:
    HTTP Status 404 - /FormGetExample/FormGetExample--------------------------------------------------------------------------------type Status reportmessage /FormGetExample/FormGetExampledescription The requested resource (/FormGetExample/FormGetExample) is not available.
    --------------------------------------------------------------------------------Apache Tomcat/5.0.28
      

  3.   

    action应该写FormGetExample1吧
      

  4.   

    是不是我的server.xml配置有问答题?
    action改为FormGetExampole1也不行。
    急急急!!!
      

  5.   

    action写的不对,应该为
    action="FormGetExample1"
    不行就试试
    action="/FormGetExample1"
    action="./FormGetExample1"
      

  6.   

    <url-pattern>/FormGetExample1 </url-pattern> 
      

  7.   

    首先最好不要把这么名字搞成一样,容易混掉 ,把下面两个地方改下试试<form name="form" method="get" action="FormGetExample1"> <input type="submit" name="submit" value="确定"> 
    <input type="reset" name="reset" value="重来"> 
      

  8.   

    <servlet> 
    <servlet-name>FormGetExample1 </servlet-name> 
    <display-name>FormGetExample1 </display-name> 
    <description>FormGetExample1 </description> 
    <servlet-class>这里应该把FormGetExample1所在包名写完整 </servlet-class> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>FormGetExample1 </servlet-name> 
    <url-pattern>这里必须有/FormGetExample1 </url-pattern> 
    </servlet-mapping> 
    还有页面FORM中的ACTION="这里应该写配置文件中的<url-pattern>中的地址:/FormGetExample1 "
      

  9.   

    action="http://localhost:8080/servlet/FormGetExample1"
    改为
    action="/FormGetExample1"
      

  10.   

    我改为url-pattern>/FormGetExample1   </url-pattern>之后运行出现下列问题,不知道是怎么回事???请高手指教下列是什么意思:
    HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception javax.servlet.ServletException: Wrapper cannot find servlet class FormGetExample1 or a class it depends on
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
    org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
    org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
    org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
    java.lang.Thread.run(Unknown Source)
    root cause java.lang.ClassNotFoundException: FormGetExample1
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1340)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
    org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
    org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
    org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
    java.lang.Thread.run(Unknown Source)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
      

  11.   

    <servlet> 
    //这里名字要与mapping的名字对应
    <servlet-name>FormGetExample1 </servlet-name> 
    <display-name>FormGetExample1 </display-name> 
    <description>FormGetExample1 </description> 
    //这里是FormGetExample1这个类的路径,也要包括包的名字
    <servlet-class>FormGetExample1 </servlet-class> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>FormGetExample1 </servlet-name> 
    这里是JSP页面的引用路径
    <url-pattern>/FormGetExample1 </url-pattern> 
    </servlet-mapping> 
    action="http://localhost:8080/servlet/FormGetExample1" 
    改为 
    action="/FormGetExample1"
    这样检查下应该就可以了。
      

  12.   

    大哥! 你action是跳转的控制器的。你给一个tomcat的端口号做什么
    比如
    action="../../Test"
      

  13.   

    我想问一下zhuyl_wind :servlet的文件放在哪了?
      

  14.   

    action里面的這么寫action="http://localhost:8080/servlet/FormGetExample1" 提交不到你的工程 直接寫FormGetExample1好了