jAVA/JS 转码解码(URLEncoder.encode decodeURIComponent)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_34169240/article/details/78866222

引用包:import java.net.URLDecoder;


Java解码:

String s  = URLDecoder.decode(URLDecoder.decode(templateObj.getString("templateContent"), "UTF-8"),"UTF-8");
s = URLDecoder.decode(URLDecoder.decode(s, "UTF-8"),"UTF-8");

Java转码:

URLEncoder.encode(name,"UTF-8");


JS转码:

tplData['templateContent'] =encodeURIComponent(encodeURIComponent(encodeURIComponent(encodeURIComponent(tempItemData['templateContent']))));

JS解码:

var originalTemplateContent = decodeURIComponent(decodeURIComponent(decodeURIComponent(decodeURIComponent(templateData.originalTemplateContent))));
   


        

Java解码:

String s  = URLDecoder.decode(URLDecoder.decode(templateObj.getString("templateContent"), "UTF-8"),"UTF-8");
s = URLDecoder.decode(URLDecoder.decode(s, "UTF-8"),"UTF-8");

Java转码:

URLEncoder.encode(name,"UTF-8");


JS转码:

tplData['templateContent'] =encodeURIComponent(encodeURIComponent(encodeURIComponent(encodeURIComponent(tempItemData['templateContent']))));

JS解码:

var originalTemplateContent = decodeURIComponent(decodeURIComponent(decodeURIComponent(decodeURIComponent(templateData.originalTemplateContent))));
    

猜你喜欢

转载自blog.csdn.net/qq_34169240/article/details/78866222
今日推荐