【发布时间】:2013-02-17 02:44:13
【问题描述】:
这是我的问题:
Camping 在问号处拆分网址。
如果我们有这样的代码:
Camping.goes :CodeLine
module CodeLine::Controllers
class Index
def get
render :index
end
end
class TextEntered < R '/(.*)'
def get(textStringEntered)
"#{textStringEntered}"
end
end
end
module CodeLine::Views
def index
html do
head do
title "Uh Oh"
end
body do
text "Looks like you got to the index"
br
br
form :name => "input" do
input :type => "text", :name => "text"
input :type => "submit", :value => "Submit"
end
end
end
end
end
运行camping path/to/file
在浏览器中转到localhost:3301 并在文本字段中输入一些文本并点击提交后,您应该会看到斜杠后面的所有内容,但它会在问号处拆分网址,因为它认为斜杠后面没有任何内容,它会将您带到索引。
问题:
是否可以设置input 使其不使用问号,或者我可以让露营不在问号处拆分?
附录 A
测试于
1. 谷歌浏览器
2.火狐
3. 野生动物园
【问题讨论】:
-
问号是 URL 中的一个特殊字符,表示它之前的所有内容都是路径,之后的每个内容都是查询字符串。这是您构建 url 的方式,还是您尝试访问名称中包含问号的资源?如果是后者,请尝试使用编码
%3F替换问号。 -
@Zach Kemp - 我可以构造不带问号的 URL 吗?例如。 example.com/text=foobarbazqux 而不是 example.com/?text=foobarbazqux
标签: ruby model-view-controller url camping markaby