zoukankan      html  css  js  c++  java
  • jsp到action 传递url时中文出现乱码

    先在jsp编码,再在action中解码

    encodeURI(encodeURI("中文"))编码

    URLDecoder.decode(request.getParameter("参数名"),"UTF-8");完成解码。

    例如:  url:"qtypenums.action?typeid=<s:property value='typeid'  escape='false'/>&qmobile=<s:property value='qmobile'  escape='false'/>&qname="+encodeURI(encodeURI('<s:property value='qname'  escape='false'/>'))+"&qattr1="+encodeURI(encodeURI('<s:property value='qattr1'  escape='false'/>'))+"&qattr2="+encodeURI(encodeURI('<s:property value='qattr2'  escape='false'/>'))+"&qattr3="+encodeURI(encodeURI('<s:property value='qattr3'  escape='false'/>')),

    在action中解码

    String qname=this.getQname();
            String qattr1=this.getQattr1()==null?"":this.getQattr1();
            String qattr2=this.getQattr2()==null?"":this.getQattr2();
            String qattr3=this.getQattr3()==null?"":this.getQattr3();
            String qname1="";
            String qattr11="";
            String qattr21="";
            String qattr31="";
            try{
                qname1=URLDecoder.decode(qname,"UTF-8");
                qattr11=URLDecoder.decode(qattr1,"UTF-8");
                qattr21=URLDecoder.decode(qattr2,"UTF-8");
                qattr31=URLDecoder.decode(qattr3,"UTF-8");
            }catch(Exception w){}

  • 相关阅读:
    netty编译报错
    idea快捷键:查找类中所有方法的快捷键
    vue修改浏览器的标题title
    django使用原生SQL的方法
    js 动态刷新页面日期
    H.264中的SPS和PPS
    CppProperties.json 参考
    FFmpeg代码导读——HEVC在RTMP中的扩展
    FFmpeg从入门到精通:SEI那些事
    FFmpeg代码导读——基础篇
  • 原文地址:https://www.cnblogs.com/danica/p/2123556.html
Copyright © 2011-2022 走看看