MyException - 我的异常网
当前位置:我的异常网» Java Web开发 » 为什么小弟我的配置都是对了,servlet在浏览器里还是

为什么小弟我的配置都是对了,servlet在浏览器里还是显示不出来啊

www.MyException.Cn  网友分享于:2013-12-22  浏览:26次
为什么我的配置都是对了,servlet在浏览器里还是显示不出来啊?
//这是我的servlet文件,有class文件在dopost\WebRoot\WEB-INF\classes\post下生成
package   post;

import   java.io.IOException;
import   java.io.PrintWriter;
import   java.util.Enumeration;

import   javax.servlet.ServletException;
import   javax.servlet.http.HttpServlet;
import   javax.servlet.http.HttpServletRequest;
import   javax.servlet.http.HttpServletResponse;

public   class   SerPost   extends   HttpServlet
{
private   static   final   String   CONTENT_TYPE   =   "text/html;charset=GBK ";
public   void   init()   throws   ServletException{}
public   void   doPost(HttpServletRequest   request,   HttpServletResponse   response)
throws   ServletException,IOException
{
request.setCharacterEncoding(CONTENT_TYPE);
PrintWriter   out   =   response.getWriter();
out.println( " <html> ");
out.println( " <head> \n <title> \nSerPost\n </title> \n </head> ");
out.println( " <body> ");
out.println( " <p> The   Servlet   has   received   a   POST.This   is   the   reply. </p> ");
Enumeration   e   =   request.getParameterNames();
while   (e.hasMoreElements())
{
String   name   =   (String)e.nextElement();
String   value   =   request.getParameter(name);
out.println(name+ "=== "+value);
}
out.println( " </body> \n </html> ");
}
public   void   destroy(){}

}

//我的jsp文件,路径dopost\WebRoot\dopost.jsp这个可以显示
<%@   page   language= "java "   pageEncoding= "UTF-8 "%>

<html>
    <head>

<meta   http-equiv= "Content-Type "   content= "text/html;charset=UTF-8 ">
        <title> DoPost </title>
       
    </head>
   
    <body>
        <form   action= "/SerPost "   method= "post ">
        <p> Press   Submit   to   post   to   Servlet   SerPost </p>
        <p> name::: <input   type= "text "   name= "name "   value= " "> </p>
        <p> password::: <input   type= "text "   name= "password "   value= " "> </p>
        <p> <input   type= "submit "   name= "Submit "   value= "Submit ">
        <input   type= "reset "   value= "Reset "> </p>
        </form>
    </body>
</html>

//我的web.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>

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有