当前位置:网站首页>GET请求如何传递数组参数
GET请求如何传递数组参数
2022-07-01 13:38:00 【明快de玄米61】
方式一
可以将数组参数传递多次,springmvc会将多个同名参数自动封装成数组或者集合对象,示例如下:
# 请求URL
http://127.0.0.1:8080/getUsers?name=张三&name=李四
# 后台接口代码
@RestController
@RequestMapping("/")
public class SpringMvcController {
@RequestMapping(value = "/getUsers", method = RequestMethod.GET)
# String[] name也可以切换为List<String,String> name
public String getUsers(@RequestParam String[] name) {
return name[0] + " " + name[1];
}
}
方式二
直接将数组指用逗号分隔,示例如下:
# 请求URL
http://127.0.0.1:8080/getTeachers?name=王五,刘麻子
# 后台接口代码
@RestController
@RequestMapping("/")
public class SpringMvcController {
@RequestMapping(value = "/getTeachers", method = RequestMethod.GET)
# String[] name也可以切换为List<String,String> name
public String getTeachers(@RequestParam String[] name) {
return name[0] + " " + name[1];
}
}
边栏推荐
- When you really learn databinding, you will find "this thing is really fragrant"!
- 8款最佳实践,保护你的 IaC 安全!
- 面试题目总结(1) https中间人攻击,ConcurrentHashMap的原理 ,serialVersionUID常量,redis单线程,
- [machine learning] VAE variational self encoder learning notes
- 小程序- view中多个text换行
- Simplex, half duplex, full duplex, TDD and FDD
- [sword finger offer] 55 - I. depth of binary tree
- B站被骂上了热搜。。
- Spark source code (V) how does dagscheduler taskscheduler cooperate with submitting tasks, and what is the corresponding relationship between application, job, stage, taskset, and task?
- 5. Use of ly tab plug-in of header component
猜你喜欢

5G工业网关的科技治超应用 超限超重超速非现场联合执法

Spark source code (V) how does dagscheduler taskscheduler cooperate with submitting tasks, and what is the corresponding relationship between application, job, stage, taskset, and task?

Animesr: learnable degradation operator and new real world animation VSR dataset

Yan Rong looks at how to formulate a multi cloud strategy in the era of hybrid cloud

当你真的学会DataBinding后,你会发现“这玩意真香”!

QT社团管理系统

What is the future development direction of people with ordinary education, appearance and family background? The career planning after 00 has been made clear

终端识别技术和管理技术

Terminal identification technology and management technology

Station B was scolded on the hot search..
随机推荐
Listen in the network
04 redis source code data structure dictionary
Station B was scolded on the hot search..
Beidou communication module Beidou GPS module Beidou communication terminal DTU
Simplex, half duplex, full duplex, TDD and FDD
微机原理与接口技术知识点整理复习–纯手打
leetcode 322. Coin change (medium)
Introduction to topological sorting
LeetCode重建二叉树详解[通俗易懂]
Have you ever encountered the problem that flynk monitors the PostgreSQL database and checkpoints cannot be used
word2vec训练中文词向量
Anti fraud, refusing to gamble, safe payment | there are many online investment scams, so it's impossible to make money like this
6年技术迭代,阿里全球化出海&合规的挑战和探索
China NdYAG crystal market research conclusion and development strategy proposal report Ⓥ 2022 ~ 2028
String input function
Analysis report on production and marketing demand and investment forecast of global and Chinese diamond powder industry Ⓤ 2022 ~ 2027
6. Wiper part
The 14th five year plan of China's environmental protection industry and the report on the long-term goals for 2035 Ⓖ 2022 ~ 2028
JVM有哪些类加载机制?
Dragon lizard community open source coolbpf, BPF program development efficiency increased 100 times