在JavaScript中,为什么我应该使用encodeURI/encodeURIComponent
In JavaScript Why should I use encodeURI/encodeURIComponent?
我知道他们2会在发送到服务器之前对URL进行编码,但这样做的原因是什么?
我以前从未在我的项目中使用过encode函数,一切都很顺利。
所以我很好奇在什么情况下我们需要使用它们,如果没有,会出现什么问题。
http://www.mywebsite.com/save-dudes-long-message?message=Hi mom! This message will break this URL request, won't it? Question marks and things like that don't fly!! #@#$!
某些字符,如"?"、"&"或"#",是为浏览器URL保留的。如果你不逃离它们,浏览器/服务器会误解你的请求并发送其他内容。
对其进行编码将转换这些字符,以便在服务器端对其进行解编码之前不会对其进行字面解释。
相关文章:
- javascript encodeURI() output
- POST encodeURI查询字符串内部服务器错误 500
- 在JavaScript中,为什么我应该使用encodeURI/encodeURIComponent
- Javascript encodeURI重定向上的omponent问题
- encodeURI在二进制字符串上处理数据
- Javascript mailto 字符串丢失了“encodeURI”编码
- 使用encodeURI组件并在服务器端对其进行解码
- 使用encodeURI()时,在回发之前显示编码的文本
- Javascript-encodeURI()在不同的浏览器中返回不同的结果
- encodeURI文件下载-浏览器崩溃
- 在JavaScript中使用encodeURI()和escape()来处理utf-8字符串
- JS的encodeURI()和PHP的urldecode()结果不同
- gsp, groovy, encodeURI组件,内联javascript
- NodeJS encodeURI产生错误的结果ß
- JQuery - Ajax: encodeUriComponent不工作(EncodeUri工作)
- javascript转义、encodeURI和encodeURIComponent的问题
- Javascript: encodeURI() / encodeURIComponent() charset