3 Java金币
刚开始做Dynamic Web Project,然后发现第一个HTML 都不能正常显示,做SE的时候环境变量已经配置好,html的jar插件也下了。
下面是html和Servlet 的内容,麻烦大家帮忙看一下是什么问题
html:
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>FORM DEMO</h1>
<form action="http://localhost:8080/firstdemo/show" method="post">
<p>
<label for="firstname">First name:</label><input type="text"
id="firstname" name="firstname"><br>
<label
for="lastname">Last name:</label>
<input type="text" id="lastname"
name="lastname"><br>
<label for="email"> email:
</label><input type="text" id="email" name="email"><br>
<input
type="radio" name="sex" value="Male">Male<br><input
type="radio" name="sex" value="Female">Female<br><input
type="submit" value="send"><input type="reset">
</p>
</form>
</body>
</html>
然后这个是Servlet:
package controller;
import java .io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class DisplayServlet
*/
@WebServlet("/show")
public class DisplayServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public DisplayServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
// response.getWriter().append("Served at: ").append(request.getContextPath());
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String f=request.getParameter("firstname");
String l=request.getParameter("lastname");
String e=request.getParameter("email");
String s=request.getParameter("sex");
PrintWriter out=response.getWriter();
out.println("<HTML><BODY>");
out.println("<H1>THIS IS MY SECOND SERVLET</h1>");
out.println("<ul>");
out.println("<li>"+f);
out.println("<li>"+l);
out.println("<li>"+e);
out.println("<li>"+s);
out.println("</HTML></BODY>");
}
}
然后这个是错误提示:
HTTP Status 404 -
type Status report
message
description The requested resource is not available.
Apache Tomcat/8.0.29
我把Tomcat8.0和eclipse都重装了,找了好几天都不知道是怎么回事。麻烦大家帮忙看看是哪里的问题,多谢了
我来回答