zoukankan      html  css  js  c++  java
  • jsp传中文乱码问题 encodeURIComponent()编码方法

    方法一:

    jQuery.ajax({
                type:"POST",
                url:"${ctx}/offer.do",
                data:{
                    'method':'isNameExist',
                    'type':'area',
                    'id':id==""?null:id,
                    'name':encodeURIComponent(offerAreaName)
                },
                async:false,
                success:function (data) {
                    bool = data;
                }
            });

    action里特别设置:

    String offerAreaName= request.getParameter("offerAreaName");
      if(StringUtils.isNotEmpty(offerAreaName)){
         productName = new String(offerAreaName.getBytes("iso8859-1"),"UTF-8");
      }

    方法二:

    window.encodeURI(window.encodeURI(strBuf)) 编译后在传

    处理方法中(action 或者 service):

    try {
       strBuf= java.net.URLDecoder.decode(strBuf,"UTF-8");
      } catch (UnsupportedEncodingException e) {
       e.printStackTrace();
      }

  • 相关阅读:
    git
    搁置:vue-element-admin
    JS
    开发心得
    CSS
    VSCode(主进程)
    Vue
    axios
    滚动条出现的原理
    element-ui 1.4.13
  • 原文地址:https://www.cnblogs.com/xtreme/p/3786404.html
Copyright © 2011-2022 走看看