java程序编写过程中,由于字符集不同导致的问题不少,遇到这种问题也不要着急,搞清楚涉及到的字符集及相互转换即可。贴个例子:
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>   
<%   
String path = request.getContextPath();   
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";   
%>   
<%@ page contentType="text/html; charset=gb2312"%>   
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">   
<html>   
  <head>   
  </head>     
  <body>   
   <%      
    request.setCharacterEncoding("gb2312");   
    String phone = request.getParameter("Mobile");   
    String Msg =new String(request.getParameter   ("Message").getBytes("ISO-8859-1"),"gb2312");     /** ohter code*/  
    %>   
  </body>   
</html>  
 
 
 
String Msg =new String(request.getParameter   ("Message").getBytes("ISO-8859-1"),"gb2312");  //这句涉及到字符集转换
 
转自唐山迪锐IT技术论坛:http://bbs.tsp2c.cn/?fromuid=135<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />