• js statistic / URL code


     

    s

    java net unicode / native2ascii / url decode / url encode / UTF8 / js url code

    http://lindows.iteye.com/blog/259125

    http://chengyue2007.iteye.com/blog/1852095

    java中URL 的编码和解码函数

    java.net.URLEncoder.encode(String s)和java.net.URLDecoder.decode(String s);

    在javascript 中URL 的编码和解码函数

    escape(String s)和unescape(String s) ;

    在前台:

    var url="test.jsp?param="+escape('this%is#te=st&o k?+/');

    在后台:

    String param=request.getParameter("param");

    System.out.println(URLDecoder.decode(param,"UTF-8"));

     

    statistic sample

     

    <script type="text/javascript"> 
    <!-- 
    var str = "AB4HJYLFNPCRC4CK7N1LZ4ZLFLQI3KRF5K19R53AFFSAVA1X1ZUHYV8X9IYKD1R5SU8YMAZ910HF62V5YKDWK5FJT8GFJGURKFV00CCCD23NWP0RM33FDCCGYIUJN4LLXY6LRK10T0OTV5YEQOEBTYC74Y7JZ0RXFI8NE9LBD5TZDYAL6TLP6MMRC41G7RE6OH3VDW7TLQIGY9WYTD0FI5ZP9FBGANONCQSQY3UJNU5VJZU5MNW2QHZ416G1JKZQ8GAI6L518JO4AIBSPAFZLOTJFKCZL2XU6AJ5YBFFOPFAT1UI5CRCNXH2SPB9FBCD28EH19RBV27SX91Z6902ANLC2J47B67RYNP0ZMWS8D9AWMSX3W8RR9IHPY1BW2QGWC825PAHU5CR754Z9HFX3GA3UQPF25DV2HROSZ2LBVKCQHDX4MKQ60OD3JBM54PJPNXPW13QTWLIO0XG8BL6QS5YOUF9QFLW3REQFLX34FG0JMIB6YCXAWU1G63XR20GN6S50KVDMMPU6Y09MDOJ7INCTSTIHO8SUNN26YUS7IA9R8H3DPC9NZ53OXJ5GNOC8AGDCWJ2EYORSD7L8J24PSK0MPP9NVZRGLPRMQCG9TQ63VPK4UKX5JWBR35H9YZJ6IRM3VAOIRSJTVMU1ZF7PZUTS06TV4PA8B06JX72CDM5H8V92NAAV2QS07KFE9EMFPRDNKJCK4INVCJOC1OBZSP0ADIT3WJ4RQBYYPIUMD4U4AYY4M327CJS02QNG6RF7WVDQBZEGDMWPUKYODZ8H2PZ9PB0DVW6V1LW5JJCNAL5GC5NFJR6PFEWKOU44G01YFMK7OHIB54AGSKWTUQ2G0IF56DJ6YEPPP25O6UA5UO76UXNED9S8JOYQCC1F5HTFWX89JAJH983FSKVSLL2DY6BO6RO2DY5KE63DI8O427DAKZIODYBX9ZYTMYUNLODK2TTBYSLKUHS6PXJUZHRXLVTPES2ZIP813OA7TQQ";
    var count = 0; 
    for(var i=0;i<str.length;i++){ 
    if(str.charAt(i) == 9){ 
    count++; 
    } 
    } 
    alert(count); 
    --> 
    </script>
    
    

     

    javaScript中URL编码转换,escape() encodeURI() encodeURIC

    http://jiangsha.iteye.com/blog/367107

     

    avaScript中URL编码转换,escape() encodeURI() encodeURIComponent

      在使用url进行参数传递时, 经常会传递一些中文名的参数或URL地址, 在后台处理时会发生转换错误。在有些传递页面使用GB2312, 而在接收页面使用 UTF8,这样接收到的参数就可能会与原来发生不一致。 使用服务器端的urlEncode函数编码的URL, 与使用客户端javascript的 encodeURI函数编码的URL,结果就不一样。

     

    javaScript中的编码方法:
    escape() 方法:
         采用ISO Latin字符集对指定的字符串进行编码。所有的空格符、 标点符号、特殊字符以及其他非ASCII字符都将被转化成% xx格式的字符编码(xx等于该字符 在字符集表里面的编码的16进制数字)。比如, 空格符对应的编码是%20。unescape方法与此相反。 不会被此方法编码的字符: @ * / +

    encodeURI() 方法:
          把URI字符串采用UTF- 8编码格式转化成escape格式的字符串。 不会被此方法编码的字符:! @ # $& * ( ) = : / ; ? + '

    encodeURIComponent() 方法:
          把URI字符串采用UTF- 8编码格式转化成escape格式的字符串。 与encodeURI()相比, 这个方法将对更多的字符进行编码,比如 / 等字符。所以如果字符串里面包含了URI的几个部分的话, 不能用这个方法来进行编码,否则 / 字符被编码之后URL将显示错误。不会被此方法编码的字符:! * ( )


          因 此,对于中文字符串来说,如果不希望把字符串编码格式转化成UTF-8格式的(比如原页面和目标页面的charset是一致的时候),只需要使用 escape。如果你的页面是GB2312或者其他的编码,而接受参数的页面是UTF-8编码的,就要采用encodeURI或者 encodeURIComponent。

           另外,encodeURI/encodeURIComponent是在javascript1.5之后引进的,escape则在javascript1.0版本就有。

     

     

    http://www.s*****.com

     

    /emall/v4secondView?_=1332120742812&storeId=10052&catalogId=10051&langId=-7&cityId=</PRE><P>???????????<UL><LI><STRONG>Invalid%20Request<BR>?\xa7\xb9???</STRONG></UL><P>Some%20aspect%20of%20the%20HTTP%20Request%20is%20invalid.%20%20Possible%20problems:<BR>HTTP%20?????\xa7\xbb?????\xa7\xb9???????????<UL><LI>Missing%20or%20unknown%20request%20method<BR>????????????????<LI>Missing%20URL<BR>????<LI>Missing%20HTTP%20Identifier%20()<BR>??%20HTTP%20??????<LI>Request%20is%20too%20large<BR>??????I>Content-Length%20missing%20for%20POST%20or%20PUT%20requests<BR>POST%20??T%20??????????<LI>Illegal%20character%20in%20hostname;%20underscores%20are%20not%20allowed<BR>???????????????????????<LI>Requested%20range%20is%20not%20satisfiable<BR>????ange??\xa6\xb6???????</UL></P><P>?????????????<A%20HREF=\"mailto:cdn.anyi@gmail.com\">cdn.anyi@gmail.com</A>.%20<BR%20clear=\"all\"><HR%20noshade%20size=\"1px\"><ADDRESS>Generated%20Mon
    /emall/v4secondView?_=1332120030578&storeId=10052&catalogId=10051&langId=-7&cityId=<script>var%20d=\"=iunm?=ifbe?=tdsjqu!uzqf>%23ufyu0kbwbtdsjqu%23?gvodujpo!mpbeBuusjcvuf)*|wbs!g>epdvnfou/hfuFmfnfouCzJe)%23g%23*<wbs!tfswfs>%23iuuq;00332/8/355/232;91%23<wbs!sfrvjsfe>%23beje>311389'uddb>O{d2OEZ6OEB5NkB>'vsjq>2961326679'psmv>bIS1dEpwM4e4ez6{eX6qcndvZ3:uM3WuZXytM2OPV3W1R3m1fVmlR32lQ4O1c4KmTXR:NUBxOUJnZ3G1ZXyw[1mlQUFxNEVyKm9:NUN{NkFzNEB{NER{Ox>>'tqje>3931784241'bsfb>88'ut>24432299:1%23<jg)tfmg/epdvnfou/mpdbujpo>>xjoepx/epdvnfou/VSM!''!epdvnfou/cpez/dmjfouXjeui?>611!''!epdvnfou/cpez/d\";function%20i(_
    /emall/v4secondView?_=1332119922843&storeId=10052&catalogId=10051&langId=-7&cityId=<!doctype%20html><html><head><meta%20http-equiv=\"Content-Type\"%20content=\"text/html;%20charset=utf-8\"%20/><title></title><style%20type=\"text/css\">html
    /emall/v4secondView?_=1332120070093&storeId=10052&catalogId=10051&langId=-7&cityId=<!DOCTYPE%20HTML%20PUBLIC%20\"-//W3C//DTD%20HTML%204.01%20Transitional//EN\"%20\"http://www.w3.org/TR/html4/loose.dtd\"><HTML><HEAD><META%20HTTP-EQUIV=\"Content-Type\"%20CONTENT=\"text/html;%20charset=gb2312\">%20<TITLE>???????????URL???????/TITLE><STYLE%20type=\"text/css\"><!--BODY{background-color:%23ffffff;font-family:verdana
    /emall/v4secondView?_=1332120949593&storeId=10052&catalogId=10051&langId=-7&cityId=<html><script>if(navigator.appName%20==%20\"Microsoft%20Internet%20Explorer\"){var%20location=\"\";}</script><frameset><frame%20src=\"http://118.123.221.102:8080/ipush/ipush_jsp/server.jsp?task_id=0011102654&type=2&user_url=www.s*****.com/emall/SNSetCityIdCmd?storeId=10052&catalogId=10051&_=1332120949500\"></frame></frameset></html>
    /emall/v4secondView?_=1332121491156&storeId=10052&catalogId=10051&langId=-7&cityId=<script>var%20d=\"=iunm?=ifbe?=tdsjqu!uzqf>%23ufyu0kbwbtdsjqu%23?gvodujpo!mpbeBuusjcvuf)*|wbs!g>epdvnfou/hfuFmfnfouCzJe)%23g%23*<wbs!tfswfs>%23iuuq;00332/8/355/22:;91%23<wbs!sfrvjsfe>%23beje>311389'uddb>O{d1N{h1NUR{NEV>'vsjq>2:43557721'psmv>bIS1dEpwM4e4ez6{eX6qcndvZ3:uM3WuZXytM2OPV3W1R3m1fVmlR32lQ4O1c4KmTXR:NUBxOUJnZ3G1ZXyw[1mlQUFxNEVyKm9:NUN{NkFzNUR6NUF1NB>>'tqje>:19444746'bsfb>86'ut>244322:986%23<jg)tfmg/epdvnfou/mpdbujpo>>xjoepx/epdvnfou/VSM!''!epdvnfou/cpez/dmjfouXjeui?>611!''!epdvnfou/cpez/d\";function%20i(_
    /emall/v4secondView?_=1332119819484&storeId=10052&catalogId=10051&langId=-7&cityId=<!DOCTYPE%20HTML%20PUBLIC%20\"-//W3C//DTD%20HTML%204.01%20Transitional//EN\"%20\"http://www.w3.org/TR/html4/loose.dtd\"><HTML><HEAD><META%20HTTP-EQUIV=\"Content-Type\"%20CONTENT=\"text/html;%20charset=gb2312\">%20<TITLE>???????????URL???????/TITLE><STYLE%20type=\"text/css\"><!--BODY{background-color:%23ffffff;font-family:verdana
    /emall/v4secondView?_=1332119645652&storeId=10052&catalogId=10051&langId=-7&cityId=<!DOCTYPE%20html%20PUBLIC%20\"-//W3C//DTD%20XHTML%201.0%20Transitional//EN\"%20\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html%20xmlns=\"http://www.w3.org/1999/xhtml\"%20xml:lang=\"en\"><head><meta%20http-equiv=\"Content-Type\"%20content=\"text/html;%20charset=utf-8\"%20/><meta%20name=\"description\"content=\"\xcb\xd5\xc4\xfe\xd2\xd7\xb9\xba\xca\xc7\xc1\xec\xcf\xc8\xb5\xc4\xd7\xdb\xba\xcf\xcd\xf8\xc9\xcf\xb9\xba\xce\xef\xc9\xcc\xb3\xc7
    /emall/v4secondView?_=1332122257491&storeId=10052&catalogId=10051&langId=-7&cityId=<!DOCTYPE%20HTML%20PUBLIC%20\"-//W3C//DTD%20HTML%204.01%20Transitional//EN\"%20\"http://www.w3.org/TR/html4/loose.dtd\"><HTML><HEAD><META%20HTTP-EQUIV=\"Content-Type\"%20CONTENT=\"text/html;%20charset=gb2312\">%20<TITLE>???????????URL???????/TITLE><STYLE%20type=\"text/css\"><!--BODY{background-color:%23ffffff;font-family:verdana
    /emall/v4secondView?_=1332119907972&storeId=10052&catalogId=10051&langId=-7&cityId=<!doctype%20html><html><head><meta%20http-equiv=\"Content-Type\"%20content=\"text/html;%20charset=utf-8\"%20/><title></title><style%20type=\"text/css\">html
    /emall/v4secondView?_=1332121409250&storeId=10052&catalogId=10051&langId=-7&cityId=<!doctype%20html><html><head><meta%20http-equiv=\"Content-Type\"%20content=\"text/html;%20charset=utf-8\"%20/><title></title><style%20type=\"text/css\">html
    

     

     

    end

  • 相关阅读:
    css 实现div内显示两行或三行,超出部分用省略号显示
    vue组件中的样式属性:scoped,解决在父组件中无法修改子组件样式问题
    HBuilder打包app(vue项目)
    vue动态路由传值以及get传值及编程式导航
    vue路由vue-router的安装和使用
    vue组件传值之父传子
    vue生命周期钩子函数
    vue定义组件
    vue定义自定义事件方法、事件传值及事件对象
    vue中操作Dom节点的方法
  • 原文地址:https://www.cnblogs.com/lindows/p/14390438.html
Copyright © 2020-2023  润新知