ruby-on-rails – Rails:加上用空格替换GET-Request

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – Rails:加上用空格替换GET-Request前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在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 (+).

原文链接:https://www.f2er.com/ruby/271852.html

猜你在找的Ruby相关文章