在 Rails 3 (Ruby 1.9.2) 中我发送一个请求
Started GET "/controller/action?path=/41_+"
但是参数列表是这样的:
{"path"=>"/41_ ",
"controller"=>"controller",
"action"=>"action"}
这里出了什么问题? -、* 或 . 符号工作正常,只是 + 将被空格替换。
最佳答案
这是正常的 URL 编码,the plus sign is a shorthand for a space :
Within the query string, the plus sign is reserved as shorthand notation for a space. Therefore, real plus signs must be encoded. This method was used to make query URIs easier to pass in systems which did not allow spaces.
并且来自 HTML5 standard :
The character is a U+0020 SPACE character
Replace the character with a single U+002B PLUS SIGN character (+).
关于ruby-on-rails - rails : Plus sign in GET-Request replaced by space,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6464885/