• jsp页面间传递参数 中文乱码问题(zz)


    jsp页面间传递参数 中文乱码问题

    window.location="Test.jsp?param1="+encodeURI(encodeURI(str));//对中文参数进行双层编码后再传递

    URLDecoder.decode(request.getParameter("param1"),"utf-8");//对中文参数进行解码

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    url="xxx.jsp?id="+java.net.URLEncoder.encode("中文", "UTF-8") //加码

    接收时,我们用
    String inf=request.getParameter("id");
    inf= new String(inf.getBytes("iso-8859-1"),"UTF-8"); 解码

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


    var title = document.getElementById("title");
    var url = "xxx.jsp?title="+encodeURI(title.value);//加码


    String title = new String(request.getParameter("qTitle").getBytes("iso-8859-1"),"UTF-8");解码

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    ajax传递中文乱码

     解决get请求乱码

    $.ajax({
    url: "" ,
    type: "GET",
    data: { pwd: encodeURI('周'), username: 'tl' },
    success: function(data) {
    alert(data.ok);
    },
    error: function(a, b, c) {
    alert("error==" + b);
    }

    });

  • 相关阅读:
    C++调用外部应用程序
    SVN文件加锁
    vs ComboBox显示多行
    __slots__ Python Class限制添加属性
    Python数据分析之pandas学习
    整理Lua和Unity和Lua交互文章链接
    [整理]Unity3D游戏开发之Lua
    ping telnet ssh netstat
    java rpc
    css 手机适配
  • 原文地址:https://www.cnblogs.com/yy123/p/4014985.html
Copyright © 2020-2023  润新知