是否传递查询字符串参数(其值为null)而没有等号有效? [英] Is passing a query string parameter (whose value is null) without the equals sign valid?

查看:165
本文介绍了是否传递查询字符串参数(其值为null)而没有等号有效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

变体1:

 file.jsp?parameter1=&parameter2=abc

变体2:

 file.jsp?parameter1&parameter2=abc

我知道变体1被认为有效,但变体2被视为有效吗?具体来说,参数没有值,在这种情况下是否需要等号?

I know Variation 1 is considered valid, but is variation 2 considered valid? Specifically, there is no value for the parameter, is the equals sign required in this case?

推荐答案

我认为它是有效的查询参数只包含参数名称。

I think it is valid to have query parameter with just the parameter name.

如果您熟悉Java,请查看@see UriComponentsBuilder QueryParam函数,默认情况下它为任何查询参数执行此操作null。

If you are familiar with Java, Look at the @see UriComponentsBuilder QueryParam function, by default it does this for any query parameter with null.


如果没有给出值,结果URI将仅包含查询
参数名称(即?foo而不是?foo = bar。

If no values are given, the resulting URI will contain the query parameter name only (i.e. ?foo instead of ?foo=bar.

有关详细信息,请参阅此答案。
如果url查询参数没有值,它是否有效?

See this answer for more info. Is a url query parameter valid if it has no value?

这篇关于是否传递查询字符串参数(其值为null)而没有等号有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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