如果值是哈希符号(#),如何获取请求参数值 [英] How can I get request parameter value if value is hash symbol (#)

查看:628
本文介绍了如果值是哈希符号(#),如何获取请求参数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下请求网址:

localhost:8080/MyApp/browse/alphabetical/result?startsWith=#&page=1&size=10&sort=title&order=asc

注意请求参数startsWith =#

我无法获得作为'startsWith'请求参数的值。相反,我得到一个空字符串()作为'startsWith'请求参数的值。有没有办法让作为请求参数的值?

I am unable to get "#" as the value of the 'startsWith' request parameter. Instead, I get an empty string ("") as the value of the 'startsWith' request parameter. Is there any possible way to get "#" as the value of the request parameter?

这不工作: $ {param.startsWith eq'#'}

此工作: $ { param.startsWith eq''}

如果无法解决这个问题,我将不得不求助于使用 startsWith = 0 ... startsWith = 9 而不是 startsWith =#,我真的不想要

If there is no way to handle this, I will have to resort to using startsWith=0 ... startsWith=9 instead of startsWith=#, which I really don't want

推荐答案

你不能用这样的查询字符串发送。它不会是查询字符串的一部分。

You cannot send a # with query string like that. It won't be a part of query string.

引用 RFC - 第3.4节


查询组件由第一个问题
表示标记(?)字符并以数字符号(#)字符
或URI结尾终止。

The query component is indicated by the first question mark ("?") character and terminated by a number sign ("#") character or by the end of the URI.

在发送请求之前,您需要在查询字符串中对参数进行编码。例如,在 JSP 页面中,您可以使用< c:url> JSTL标记:

You need to encode the parameters in query string, before sending request. For e.g., In a JSP page, you can use <c:url> JSTL tag:

<c:url value="/MyApp/browse/alphabetical/result" var="url">
  <c:param name="startsWith" value="#" />
  <!-- Rest of the parameters -->
</c:url>

这篇关于如果值是哈希符号(#),如何获取请求参数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆