问题描述
我正在尝试编写一个Java类来登录某个网站。在POST请求中发送的数据是
I'm trying to write a Java class to log in to a certain website. The data sent in the POST request to log in is
用户%5Blogin%5D = uesrname& user%5Bpassword%5D = 123456
我很好奇%5B
和%5D
表示密钥用户登录。
如何对这些数据进行编码?
How do I encode these data?
推荐答案
根据的回答: str ='foo%20%5B12%5D'
编码 foo [12]
:
%20 is space
%5B is '['
and %5D is ']'
这称为并用于编码url参数值中的特殊字符。
This is called percent encoding and is used in encoding special characters in the url parameter values.
编辑顺便说一下我正在阅读,我刚想到为什么这么多人进行相同的搜索。请参阅页面底部的注释:
EDIT By the way as I was reading https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURI#Description, it just occurred to me why so many people make the same search. See the note on the bottom of the page:
function fixedEncodeURI (str) {
return encodeURI(str).replace(/%5B/g, '[').replace(/%5D/g, ']');
}
希望这可以帮助人们在遇到这个问题时理清他们的问题。
Hopefully this will help people sort out their problems when they stumble upon this question.
这篇关于POST请求中的%5B和%5D代表什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!