Is it a bad practice to use a GET parameter (in URL) with no value?

前端 未结 3 1729
野性不改
野性不改 2021-01-01 16:07

I\'m in a little argument with my boss about URLs using GET parameters without value. E.g.

http://www.example.com/?logout

I see this kind of lin

3条回答
  •  既然无缘
    2021-01-01 16:38

    RFC 2396, "Uniform Resource Identifiers (URI): Generic Syntax", §3.4, "Query Component" is the authoritative source of information on the query string, and states:

    The query component is a string of information to be interpreted by the resource.

    [...]

    Within a query component, the characters ";", "/", "?", ":", "@", "&", "=", "+", ",", and "$" are reserved.

    RFC 2616, "Hypertext Transfer Protocol -- HTTP/1.1", §3.2.2, "http URL", does not redefine this.

    In short, the query string you give ("logout") is perfectly valid.

提交回复
热议问题