jsp、html、js的文件编码都是utf8吗?

解决方案 »

  1.   

    回2l:是的 都是utf-8 在不用js直接从jsp 传到servlet可以正常显示回3l:试了~~不行~~~记事本 UltraEdit都用了~~都没有用~~
      

  2.   

    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    meta标签中http-equiv属性值加上引号试试。如果文件编码都正确,那就有可能是浏览器没有使用utf-8编码来解析页面,检查一下浏览器使用的编码,也可以在浏览器菜单中指定页面编码为UTF-8试试。
      

  3.   

    google了一下,貌似通过GET方式传递中文参数值比较容易碰到乱码问题,解决方法:
    //document.location="http://localhost:8080/css/AddStuInfoServlet?sname="+document.loginform.sname.value;
    document.location="http://localhost:8080/css/AddStuInfoServlet?sname=" + encodeURIComponent (document.loginform.sname.value);servlet中:String name= new String(request.getParameter("sname").getBytes("ISO-8859-1"),"UTF-8");
      

  4.   

    request.setCharacterEncoding("utf-8");
    试试,我也是新手,不对勿怪
      

  5.   

    get方式传参会有中文乱码问题,可以处理但麻烦。建议使用post方式提交
    如:
    <form id="form1" method="post">
    </form>
    function submit(){
     document.forms["form1"].action="http://localhost:8080/css/AddStuInfoServlet";
     //document.forms["form1"].target="rightFrame";--有框架
     document.forms["form1"].submit();
    }
      

  6.   

    首先在客户端 对url地址进行两次encodeURI(encodeURI(url));然后在服务器端进行this.userName=java.net.URLDecoder.decode(this.userName,"UTF-8");进行转码。
      

  7.   

    servlet中:String name= new String(request.getParameter("sname").getBytes("ISO-8859-1"),"UTF-8");我也是这样弄得,但是提示The method String(byte[], String) is undefined for the type 肿么办?