写了个request,xml配置有问题
写了个request,估计xml配置有问题,请帮忙看下是哪里出了错。
Request的Java程序是这样的:
package mypackage;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class RequestInfo extends HttpServlet{
/**
*
*/
private static final long serialVersionUID = -5606363569551622930L;
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws
IOException,
ServletException {
response.setContentType("text/html;charset=GB2312");
PrintWriter out=response.getWriter();
out.println("<html>");
out.println("<body>");
out.println("<head>");
out.println("<title>Request Information </title>");
out.println("</head>");
out.println("<body>");
out.println("<h3>Request Information </h3>");
out.println("方法:"+request.getMethod()+"<br>");
out.println("请求URI:"+request.getRequestURI()+"<br>");
out.println("协议:"+request.getProtocol()+"<br>");
out.println("路径信息:"+request.getPathInfo()+"<br>");
out.println("远程主机地址:"+request.getRemoteAddr()+"<br>");
out.println("</body>");
out.println("</html>");
}
/*
* doPost函数中调用doGet函数
*/
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws IOException,ServletException{
doGet(request,response);
}
}
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 web-app_2_4.xsd"
version="2.4">
<display-name>Welcome to Tomcat</display-name>
<description>
study jsp
</description>
<servlet>
<servlet-name>RequestInfo</servlet-name>
<servlet-class>mypackage.RequestInfo</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RequestInfo</servlet-name>
<url-pattern>/RequestInfo</url-pattern>
<servlet-mapping>
------解决方案--------------------哪儿出问题了,你到是说说啊?是浏览器中出不了页面么?是不是xml文件中最后一行,你把这个给删除了</web-app>
有时候小问题会害死人的 !
------解决方案--------------------The markup in the document following the root element must be well-formed.
需要有格式良好的根节点元素。对应地说就是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 web-app_2_4.xsd"
version="2.4">
<display-name>Welcome to Tomcat </display-name>
<description>
study jsp
</description>
<servlet>
<servlet-name>RequestInfo </servlet-name>
<servlet-class>mypackage.RequestInfo </servlet-