在webapps文件目录下有servletsample/WEB-INF/classes/HelloWrold.class
servletsample/WEB-INF/目录下自己定义了一个web.xml
为什么在浏览器输入http://localhost:8080/servletsample/HelloWrold不能显示呢
在webapps文件目录下有servletsample/WEB-INF/classes/HelloWrold.class
servletsample/WEB-INF/目录下自己定义了一个web.xml
为什么在浏览器输入http://localhost:8080/servletsample/HelloWrold不能显示呢
下面是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">
<description>
A Hello Wrold Appliction
</description>
<display-name>Hello Wrold</display>
<servlet>
<servlet-name>HelloWrold</servlet-name>
<servlet-class>HelloWrold</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWrold</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("<html><head><title>Hello World</title></head>");
out.println("<body><b>Hello World</b></body></html>");
out.flush();
}
}