且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

URL,哈希或查询字符串中应优先显示的是什么?

更新时间:2023-02-25 14:13:24

一些在线文章说,URL中的查询字符串和哈希没有标准

Some online articles says, that there is no standard for querystring and hash in URL

它们是错误的,或者您是在误解它们.

Either they are wrong or you are misinterpreting them.

查询字符串必须出现在片段标识符(您称为哈希)之前.

The query string must appear before the fragment identifier (which you call the hash).

规范显示URI的格式:

URI         = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

它清楚地显示了查询之后出现的片段.

It clearly shows the fragment appearing after the query.

如果哈希值紧跟查询字符串,则它可以成为某些查询字符串数据的值

if hash follows querystring, it can become a value to some querystring data

不能.#是一个特殊字符,指示片段的开始.要在查询字符串数据中包含一个,必须将其转义为%23 .

It can't. The # is a special character that indicates the start of the fragment. To include one in query string data it needs to be escaped as %23.