Is passing a query string parameter (whose value is null) without the equals sign valid?

不羁的心 提交于 2019-12-10 12:58:46

问题


Variation 1:

 file.jsp?parameter1=&parameter2=abc

Variation 2:

 file.jsp?parameter1&parameter2=abc

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?


回答1:


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

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

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

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



来源:https://stackoverflow.com/questions/21291562/is-passing-a-query-string-parameter-whose-value-is-null-without-the-equals-sig

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!