- 论坛徽章:
- 0
|
为何servlet的java程序编译编译通过了,却在浏览器的地址栏输入地址后提示404错误
环境:jdk6.0+tomcat6.0
1.helloworld.java
package test;
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class helloworld extends GenericServlet{
public void init(ServletConfig config)throws ServletException
{
super.init(config);
log("servlet has been inited now");
}
public void service(ServletRequest request,ServletResponse response)throws IOException,ServletException
{
PrintWriter out=response.getWriter();
response.setContentType("text/html,charset=gbk");
out.print("");
out.print("");
out.print("the first servlet");
out.print("");
out.print("");
out.print("第一个servlet运行成功!
");
out.print("info:"+this.getServletInfo());
out.print("");
out.print("");
}
public String getServletInfo()
{
return "the first servlet,by caxton!";
}
public void destroy()
{
System.out.print("the first servlet,destroyed!");
}
}
2.编译
![]()
3. 修改web.xml
Welcome to Tomcat
Welcome to Tomcat
helloworld
test.helloworld
helloworld
>/helloworld
4.输入地址
http://localhost:8080/10/helloworld
显示为:
HTTP Status 404 - /10/helloworld
type Status report
message /10/helloworld
description The requested resource (/10/helloworld) is not available.
Apache Tomcat/6.0.16
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/77907/showart_1220124.html |
|