两个文件:web.xml和Test.java
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><h3>This is a servlet test.</h3></body></html>");
out.flush();
}
}<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC"-//Sun Microsystems,Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>test</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>Test</servlet-name> <servlet-class>test.Test</servlet-class> </servlet> <servlet-mapping> <servlet-name>Test</servlet-name> <url-pattern>/Test</url-pattern> </servlet-mapping> </web-app>
运行不出来 一直404 心塞...
万千封印
猛跑小猪
SMILET
相关分类