SpringMVC+Thymeleaf如何处理URL中的动态查询参数

本文介绍了在Spring MVC框架中如何使用@RequestParam注解处理HTTP请求中的参数。具体讲解了通过Map<String,String>来接收单一参数的情况,以及使用MultiValueMap<String,List<String>>处理多个相同名称的参数的方法。

1.使用一个Map<String, String>接收数据

When you request a Map annotated with @RequestParam Spring creates a map containing all request parameter name/value pairs. If there are two pairs with the same name, then only one can be in the map. So it's essentially a Map<String, String>

You can access all parameters through a MultiValueMap:

public String processGetRequest(@RequestParam MultiValueMap parameters) {

This map is essentially a Map<String, List<String>>. So parameters with the same name would be in the same list.

2.

转载于:https://www.cnblogs.com/hyl8218/p/5892808.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值