开发者

how to append a list in href url?

开发者 https://www.devze.com 2022-12-17 06:00 出处:网络
I want to append a list in the url that is a href ,how can do so and h开发者_C百科ow can i read it using request.getParameter() ? or a complete bean object in the url ?Use the same name for every item

I want to append a list in the url that is a href ,how can do so and h开发者_C百科ow can i read it using request.getParameter() ? or a complete bean object in the url ?


Use the same name for every item, build something like this, http://example.com/somepath?amt=1&amt=2&amt=3.

And then you can use HttpServletRequest.getParameterMap(). Or alternatively, you can use HttpServletRequest.getParameterValues(name). You might like to use the latter by specifying the name, for example,

String[] amts = request.getParameterValues("amt");

By the way, getParameterMap() will give you a Map object having parameter names as key. It will have all other request parameters as well as your 'amt'.

Map map = request.getParameterMap();
String[] amts = map.get("amt");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号