zoukankan      html  css  js  c++  java
  • 中文编码问题

    方法一:对前端传到后台的中文进行两次编码,服务器端进行一次解码。

    (更经常用encodeURIComponent编码)

    编码时:

      tree.on('beforeload',function(){

      tree.loader.dataUrl='getvisibletasktreegrid.action?taskName='+encodeURI(encodeURI($("tName").value))+'&operator='+$("tOperator").value+'&province='+encodeURI(encodeURI($("tProvince").value))+

    '&department='+encodeURI(encodeURI($("tDepartment").value))+'&profileInfo='+encodeURI(encodeURI($("profileInfo").value))+'&createTimeBegin='+

    $("createTimeBegin").value+'&createTimeEnd='+$("createTimeEnd").value+'&executeTimeBegin='+$("executeTimeBegin").value+'&executeTimeEnd='+

    $("executeTimeEnd").value+"&pageNo="+$("pageNo").value+"&pageDirection="+$("pageDirection").value+"&totalRecord="+$("totalRecord").value; 

    }

    解码时:

    if(taskName!=null && taskName.length()!=0){

               try {

                  taskName = java.net.URLDecoder.decode(taskName,"UTF-8");

               } catch (UnsupportedEncodingException e) {

                  if(Constants.logger.isErrorEnabled()){          

                         Constants.logger.error("Exception Information",e);

                  }

               }

               df.setTaskName(taskName);

    }

     

    方法二:

    JavaScript进行一次编码,后台java处理时如下。

    java代码:

    String s = new String(request.getParameter("name").getBytes("ISO8859-1"), "UTF-8");

  • 相关阅读:
    SDN概述
    Linux企业运维人员必备150个命令汇总
    自动化运维工具puppet详解(二)
    自动化运维工具puppet详解(一)
    自动化运维工具[ansible详解三]
    ansible 常用模块
    自动化运维工具【ansible详解 二】
    A. Cinema Line
    A. Wrong Subtraction
    A. The number of positions
  • 原文地址:https://www.cnblogs.com/guozhiguoli/p/3255300.html
Copyright © 2011-2022 走看看