jsp 中 , 在文本框中输入中文,传值变成乱玛 ,不能SQL查询 怎么办

解决方案 »

  1.   

    我是在 ActiongFrom里获得数据的 是把request.setCharacterEncoding("GBK"); 写在那吗?????
      

  2.   

    把JSP的編碼改成 
    <%@ page language="java" import="java.util.*" pageEncoding="GBK" contentType="text/html; charset=GBK"%> 如果不行,加個過濾器,可以用struts里的那個或者在ACTION中加上 
      request.setCharactorEncoding("GBK");response.setCharactorEncoding("GBK"); 
    如果還不行,String username = new String(userForm.getUsername().getBytes("ISO-8859-1"),"GBK"); 
    試試看
      

  3.   

    一般来说,这种直接从SERVLET输出网页到客户端,有下面两句话就OK了 
    response.setContentType("text/html; charset=GB2312"); 
    response.setCharacterEncoding("GB2312"); 
    如果不行就配过滤器,过滤器是处理乱码的主要方法,当用了过滤器仍有乱码,我們才通常采取其它方法来解决,你这种应该用过滤器才能解决 
    像这种request.setCharacterEncoding("GB2312"); 
    String naString=new String(Uname.getBytes("iso-8859-1"),"GB2312");  
    String naString = URLDecoder.decode("返回","GB2312"); 
    这些都处理请求的乱码而不是输出
      

  4.   

    保证jsp和后台程序字符集相同
    方法如4楼