如何将参数值包装在 URL 中以包含参数分隔符

发布于 2025-01-18 18:42:09 字数 438 浏览 2 评论 0原文

我正在露天项目中工作,需要发送一个值作为关键字来进行搜索。 现在,我的问题是,我可以以某种方式包装该值以包含 & 分隔符吗? 我的 URL 如下所示:

https://myproject/share/proxy/alfresco/slingshot/search?term=belux&50&qw

我作为参数发送的值是: belux&50&qw

问题是当我完成搜索时,搜索引擎会感到困惑并仅将该参数读取为 belux 。搜索引擎可能会看这个 &就像在分隔符上一样,一旦他找到它,他就会停止,也就是说,只读取第一个字符的值。 就我而言,他只阅读belux

是否可以读取整个值,包括 &视线?

谢谢,

I am working on project in alfresco, and need to send a value as a keyword to do the search.
Now, my question is, can I wrap that value somehow to include & separator also?
My URL looks like:

https://myproject/share/proxy/alfresco/slingshot/search?term=belux&50&qw

The value that I am sending as a parameter is:
belux&50&qw

The problem is when I done the search, search engine get confused and read that parameter as belux only. Probably search engine looks on that & as on separator an as soon as he finds it he stops, that is, reads the value to the first character only.
In my case, he reads only belux.

Is it posible to read the whole value, including the & sight?

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

软的没边 2025-01-25 18:42:09

urlencoder 是解决方案。您只需要记住单个查询字符串参数的名称和/或值,而不是整个URL的名称和/或值,当然也不是查询字符串参数分隔符&或参数名称值分离器字符=。
例子 :

String url = "https://example.com?q=" + URLEncoder.encode("belux&50&qw", StandardCharsets.UTF_8);

URLEncoder is the solution. You just need to remember to encode only the name and/or value of the individual query string parameter, not the whole URL, and certainly not the query string parameter separator character & or the parameter name-value separator character =.
Example :

String url = "https://example.com?q=" + URLEncoder.encode("belux&50&qw", StandardCharsets.UTF_8);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文