Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
315 views
in Technique[技术] by (71.8m points)

html - How to pass boolean variable of false in a URL

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
  • domain/page?test=
  • domain/page?test=0
question from:https://stackoverflow.com/questions/29739970/how-to-pass-boolean-variable-of-false-in-a-url

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...