本帖最后由 lyg2013 于 2013-4-7 23:21 编辑
我在安装tomcat6时 出现的问题
代码如下
package web;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class HelloServlet extends HttpServlet{
public void service(HttpServletRequest request,
HttpServletResponse response)throws ServletException,
IOException{
// 假设用户输入
// http://localhost:8080/web01/hell0?
// 获得请求数据
String name=request.getParameter("name");
// 对请求进行处理
String rs="<h1>hello"+name+"</h1>";
// 设置响应结果
PrintWriter out=response.getWriter();
out.println(rs);
out.close();
}
}
Xml配置如下
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
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">
<servlet>
<servlet-name>helloServlet</servlet-name>
<servlet-class>HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>helloServlet</servlet-name>
<url-pattern>/hello</url-pattern>
<servlet-mapping>
</web-app>
为什么在启动tomcat后
地址栏输入:http://localhost:8080/web01/hello?name=wangwu
出现这个错误呢
SEVERE: Context [/web01] startup failed due to previous errors
|