如何在URL中传递布尔值false的布尔值 [英] How to pass boolean variable of false in a URL
问题描述
我无法解决如何通过URL字符串传递布尔值为false的变量.正确的方法是什么?
I cannot work out how to pass a variable with a boolean value of false through a URL string. What is the correct method?
- domain/page?test = false
- 域/页面?test =
- 域/页面?test = 0
推荐答案
URL是字符串,URL中的所有值都是字符串.当您在URL中看到i=0
时,0
是一个字符串.当您看到b=true
时,true
是一个字符串.当您看到s=
时,该值是一个空字符串.
URLs are strings and all values in a URL are strings. When you see i=0
in a URL, 0
is a string. When you see b=true
, true
is a string. When you see s=
, the value is an empty string.
要使这些字符串具有另一种含义(例如,整数0
或布尔值true
),必须告知服务器端程序如何解释它们.通常,Web框架会对正确的类型做出明智的猜测,或者有时在模型中明确声明类型.
For those strings to take on another meaning—the integer 0
or the Boolean true
, say—the server-side program must be told how to interpret them. Often web frameworks will make intelligent guesses as to the right type, or sometimes a type is declared explicitly in a model.
如何执行完全取决于所使用的服务器端语言和框架(如果有).
How you'll do it depends entirely on what server-side language and what framework, if any, you're using.
这篇关于如何在URL中传递布尔值false的布尔值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!