HttpServletRequest - 获取查询字符串参数,无表单数据 [英] HttpServletRequest - Get query string parameters, no form data

查看:967
本文介绍了HttpServletRequest - 获取查询字符串参数,无表单数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HttpServletRequest 中, getParameterMap 返回所有查询字符串参数的Map和发布数据参数。

In HttpServletRequest, getParameterMap returns a Map of all query string parameters and post data parameters.

有没有办法获取一个只有查询字符串参数的Map?我试图避免使用getQueryString并解析出值。

Is there a way to get a Map of ONLY query string parameters? I'm trying to avoid using getQueryString and parsing out the values.

推荐答案

与cularis所说的相反,参数map。

Contrary to what cularis said there can be both in the parameter map.

我看到的最佳方法是代理参数Map,并为每个参数检索检查queryString是否包含&?< parameterName> =。

The best way I see is to proxy the parameterMap and for each parameter retrieval check if queryString contains "&?<parameterName>=".

请注意,在进行此检查之前,parameterName需要进行URL编码,正如Qerub所指出的那样。

Note that parameterName needs to be URL encoded before this check can be made, as Qerub pointed out.

你解析并仍然只给你URL参数。

That saves you the parsing and still gives you only URL parameters.

这篇关于HttpServletRequest - 获取查询字符串参数,无表单数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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