• Atitit.软件开发概念(11)--网络子系统--url编码 空格问题URLEncoder java js php


    Atitit.软件开发概念(11)--网络子系统--url编码 空格问题URLEncoder java js php 

    1. RFC2396标准

     including HTML 4.01 section 17.13.4, and also RFC 1866 (which is supercededby the W3C HTML recommendations).

    在form的ContextType是[x-www-form-urlencoded]的时候会对form中的键/值对进行编码,空格被转义成+,其它字符依照[RFC1738]标准处理成%HH的形式。

    作者::老哇的爪子Attilax艾龙,EMAIL:1466519819@qq.com

    转载请注明来源: http://blog.csdn.net/attilax

    2. Js urlencode

    js对文字进行编码涉及3个函数:escape,encodeURI,encodeURIComponent。对应3个解码函数:unescape,decodeURI,decodeURIComponent

    escape不编码字符有69个:*,+,-,.,/。@,_,0-9,a-z,A-Z

    encodeURI不编码字符有82个:!,#,$。&。'。(,)。*,+。,,-。.。/,:。;,=。?,@。_,~,0-9,a-z,A-Z

    encodeURIComponent不编码字符有71个:!, ',(,),*,-。.。_。~。0-9,a-z。A-Z

    3. 解决之道::

     s = org.tuckey.web.filters.urlrewrite.utils.URLEncoder.encodePathParam("a  b", "utf-8");//a%20%20b

    手动replace space to %20

    或者

    收到url解析时使用

    URLDecoder.decode("a++b%20c"));   //a  b c 

    4. 參考

    URL编码中的空格问题 - 来老师的专栏 - 博客频道 - CSDN.NET.htm

    js解码函数 escape,encodeURI,encodeURIComponent比較 - xuchanghao的专栏 - 博客频道 - CSDN.NET.htm

  • 相关阅读:
    Light OJ 1030
    Light OJ 1027
    [转]Learn SQLite in 1 hour
    基于 Arduino 的 RFID 识别实验
    RFID 知识的学习
    Arduino UNO R3
    浪潮之巅(第2版)- 读书笔记
    [转]周易入门三十五问答
    Nginx代码风格图示
    封神演义
  • 原文地址:https://www.cnblogs.com/yangykaifa/p/6912395.html
Copyright © 2020-2023  润新知