encodeURIComponent的使用

encodeURIComponent();


   /**
    * jQuery.post的提交中文转码(js将中文字符串encodeURIComponent(中文字符串))
    * @param string 字符串
    * @return utf-8 字符串
    */
   private String getUtf8String(String string){
       if(StringUtils.isEmpty(string)){
           return "";
       }
       try {
           return URLDecoder.decode(string, "utf-8");
       } catch (UnsupportedEncodingException e) {
           return "";
       }
   }

猜你喜欢

转载自forlab.iteye.com/blog/1910872