0

所以,我有一些额外的数据要随请求提供。

例如:

/tests/46/add_key?keyword=%D0%A0%D0%BE%D1%81%D1%81%D0%B8%D0%B8&position=22

但除此之外,我想传递颜色查询,如下所示:

 /tests/46/add_key?keyword=%D0%A0%D0%BE%D1%81%D1%81%D0%B8%D0%B8&position=22&color=#68d574

但是这种方式最终的要求是:

Started POST "/tests/46/add_key?keyword=%D1%81%D0%BA%D1%80%D0%BE%D0%BC%D0%BD%D0%BE&position=200&color="

当我将查询更改为仅使用字符串时[a-zA-Z],例如'red'

Started POST "/tests/46/add_key?keyword=%D1%81%D0%BA%D1%80%D0%BE%D0%BC%D0%BD%D0%BE&position=200&color=red"

这个请求是我所期望的。

所以,不去服务器(#68d574)的查询包含符号,我不能在请求(#)中使用。或者是什么?

你能解释一下吗

4

1 回答 1

2

The # character indicates the start of the fragment identifier, so it terminates the query string. Since the fragment id is only used client side, it isn't even sent to the server.

As with any character which has special meaning in a URI, you can include it as data by percent encoding it (in this particular case as %23).

于 2013-06-09T08:42:07.567 回答