日期:2014-05-18  浏览次数:20802 次

File--- getRequest().getParameter转码问题,????????
如题,想接收前面表单的值,之前图片已上传成功,但是其它表单的值使终为??????
试了很多方法,还不行,
<%@   page   contentType= "text/html;   charset=gb2312 "   language= "java "   import= "java.sql.* "   errorPage= " "   %>
<%
request.setCharacterEncoding( "GBK ");
SmartUpload   mySmartUpload   =new   SmartUpload();
mySmartUpload.initialize(pageContext);
mySmartUpload.upload();
-------------------
String     name1=mySmartUpload.getRequest().getParameter( "name ").trim();      
不行
-------------------
  String       str=mySmartUpload.getRequest().getParameter( "name ");
                byte       b[]=str.getBytes( "ISO-8859-1 ");    
                str=new       String(b);
还不行?
--------------
还没有涉及数据库,所以不用考虑!
急!


------解决方案--------------------
页面request.setCharacterEncoding( "GBK ");或者request.setCharacterEncoding( "gb2312 ");
表单用post提交,那server接受的就应该不存在乱码

不设置method,默认以get提交 比如name=a
server String a = new String(request.getParameter( "a ").getBytes( "iso-8859-1 "), "gb2312 ");
这个a就应该不存在乱码