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){}

  • 相关阅读:
    css控制textarea固定大小不可拖动
    js绑定回车事件
    这一周的收获与总结_BP
    20140824
    【转】Hadooop学习笔记
    【转】CUDA优化小记录
    【转】CUDA程序优化要点
    cublas 矩阵相乘API详解
    CUDA 矩阵相乘完整代码
    CUDA 矩阵相乘
  • 原文地址:https://www.cnblogs.com/danica/p/2123556.html
Copyright © 2011-2022 走看看