一个没有乱码的jsp/servlet程序 含参数传递


<% @ page contentType="text/html; charset=GB2312" language="java"   %>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html  xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta  http-equiv ="Content-Type"  content ="text/html; charset=GB2312"   />
< title > 帐号密码 </ title >
</ head >

< body >
< form  action ="../addDo"  method ="post" >
    姓名
< input  type ="text"  name ="name"    />< br  />
    密码
< input  type ="text"  name ="password"   />
    
< input  type ="submit"  value ="确定"   />
    
</ form >
</ body >
</ html >
 

 

 

package  mypack;
import  java.io. * ;
import  javax.servlet. * ;
import  javax.servlet.http. * ;


public   class  addDo  extends  HttpServlet
{
    
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
    
{
        
        response.setCharacterEncoding(
"gb2312");
        request.setCharacterEncoding(
"gb2312");
        
//response.setContentType("text/html;charset=gb2312");
        
        PrintWriter out 
= response.getWriter();
        out.println( 
"姓名4:"+request.getParameter("name"));
        out.println(
"密码4:"+request.getParameter("password"));
        out.println(
"<br/><a href='javascript:history.go(-1)'>返回</a>");
        out.println(
"<s>画横线的</s>");
    }

}


 

关键字:jsp 中文乱码   jsp页面乱码   jsp中文乱码问题   jsp 乱码问题   jsp乱码处理 jsp出现乱码   jsp 中文显示 乱码   jsp mysql 乱码   eclipse jsp 乱码   jsp汉字乱码 servlet 乱码 

 

 

你可能感兴趣的:(JavaScript,java,eclipse,jsp,mysql,servlet)