问题描述
我有以下请求网址:
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.
引用:
在发送请求之前,您需要在查询字符串中对参数进行编码。例如,在 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>
这篇关于如果值是哈希符号(#),如何获取请求参数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!