菜鸟求助问题,急!!谢谢大牛们了~

davidcoffee 2009-10-22 09:50:56
form1.html代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>form1.html</title>
</head>

<body>
<form action="/ServletForm/servlet/form1">
First Name:
<input type="text" name="firstName">
<br>
Last Name:
<input type="text" name="lastName">
<br>
<input type="submit" value="Submit Form">
</form>
</body>
</html>
相关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 form1 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println(" <HEAD><TITLE>form1</TITLE></HEAD>");
out.println(" <BODY>");
out.println("<p> firstName= " + request.getParameter("firstName") + "</p>");
out.println("<p> lastName= " + request.getParameter("lastName") + "</p>");
out.println(" </BODY>");
out.println("</HTML>");
out.close();
}

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}

}
我实现文本输入的信息通过按submit form通过servlet转跳到一个结果页面可是为什么老是报错
type Status report

message /ServletFrom/form1.html

description The requested resource (/ServletFrom/form1.html) is not available.

我的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>

<servlet-name>form1</servlet-name>
<servlet-class>ServletForm.form1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>form1</servlet-name>
<url-pattern>/servlet/form1</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
是哪里出问题了呢?是书上例题为什么单独输入http://localhost:8080/Servlet_Exercise/form1.html和http://localhost:8080/Servlet_Exercise/servlet/form1都有反应的就是不能用书上的http://localhost:88080/ServletForm/form1.html访问呢,我的工程名石Servlet_Exercise.
求助于大牛们解惑~
...全文
50 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
imasmallbird 2009-10-22
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 davidcoffee 的回复:]
谢谢你,问题解决了~万分感谢啊~
[/Quote]
不用谢~~
davidcoffee 2009-10-22
  • 打赏
  • 举报
回复
谢谢你,问题解决了~万分感谢啊~
imasmallbird 2009-10-22
  • 打赏
  • 举报
回复
<form action="/ServletForm/servlet/form1">
改为
<form action="/Servlet_Exercise/servlet/form1">
正是由于你的工程名,与你的书上的工程名不一致,所以你也要把这个路径改了`~

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧