Pass a parameter containing '%' in URL?

后端 未结 2 1792
温柔的废话
温柔的废话 2020-12-10 09:48

While passing my url, for example something:8000/something.jsp?param1=update¶m2=1000¶m3=SearchString%¶m4=3 , I am getting following erro

2条回答
  •  天涯浪人
    2020-12-10 10:36

    See this: Encode URL in JavaScript?

    Basically you need to make sure the variables you are passing are encoded (the '%' character is a special character in URL encoding).

    Any special characters - %,?,&, etc... need to be encoded. They are encoded with '%' and their hex number. So '%' should become '%25', '&' becomes '%26', etc.

    Update: see When are you supposed to use escape instead of encodeURI / encodeURIComponent? for why you should avoid using escape.

提交回复
热议问题