当前位置:网站首页>How to pass array parameters in get request
How to pass array parameters in get request
2022-07-01 13:55:00 【Mingkuai de xuanmi 61】
Mode one
You can pass array parameters multiple times ,springmvc Multiple parameters with the same name will be automatically encapsulated into an array or collection object , Examples are as follows :
# request URL
http://127.0.0.1:8080/getUsers?name= Zhang San &name= Li Si
# Background interface code
@RestController
@RequestMapping("/")
public class SpringMvcController {
@RequestMapping(value = "/getUsers", method = RequestMethod.GET)
# String[] name You can also switch to List<String,String> name
public String getUsers(@RequestParam String[] name) {
return name[0] + " " + name[1];
}
}
Mode two
Directly separate array fingers with commas , Examples are as follows :
# request URL
http://127.0.0.1:8080/getTeachers?name= Wang Wu , Liu Mazi
# Background interface code
@RestController
@RequestMapping("/")
public class SpringMvcController {
@RequestMapping(value = "/getTeachers", method = RequestMethod.GET)
# String[] name You can also switch to List<String,String> name
public String getTeachers(@RequestParam String[] name) {
return name[0] + " " + name[1];
}
}
边栏推荐
- 3.4 data query in introduction to database system - select (single table query, connection query, nested query, set query, multi table query)
- [Jianzhi offer] 55 - ii balanced binary tree
- Anti fraud, refusing to gamble, safe payment | there are many online investment scams, so it's impossible to make money like this
- [241. Design priority for operation expression]
- 研发效能度量框架解读
- 运行游戏时出现0xc000007b错误的解决方法[通俗易懂]
- Sign APK with command line
- QT学习管理系统
- 小程序- view中多个text换行
- ArrayList扩容机制以及线程安全性
猜你喜欢

What "hard core innovations" does Intel have in the first half of 2022? Just look at this picture!

The best landing practice of cave state in an Internet ⽹⾦ financial technology enterprise

2022 · 让我带你Jetpack架构组件从入门到精通 — Lifecycle

开源实习经验分享:openEuler软件包加固测试

Anti fraud, refusing to gamble, safe payment | there are many online investment scams, so it's impossible to make money like this

2022. Let me take you from getting started to mastering jetpack architecture components - lifecycle

Fiori 应用通过 Adaptation Project 的增强方式分享

Etcd 概要 机制 和使用场景

Error:Kotlin: Module was compiled with an incompatible version of Kotlin. The binary version of its

被裁三个月,面试到处碰壁,心态已经开始崩了
随机推荐
Understand the window query function of tdengine in one article
8款最佳实践,保护你的 IaC 安全!
[241. Design priority for operation expression]
【剑指 Offer】55 - II. 平衡二叉树
MySQL log
当你真的学会DataBinding后,你会发现“这玩意真香”!
Listen in the network
Summary of 20 practical typescript single line codes
A new book by teacher Zhang Yujin of Tsinghua University: 2D vision system and image technology (five copies will be sent at the end of the article)
陈宇(Aqua)-安全-&gt;云安全-&gt;多云安全
我们该如何保护自己的密码?
ArrayList capacity expansion mechanism and thread safety
2022. Let me take you from getting started to mastering jetpack architecture components - lifecycle
学会使用LiveData和ViewModel,我相信会让你在写业务时变得轻松
What "hard core innovations" does Intel have in the first half of 2022? Just look at this picture!
Etcd summary mechanism and usage scenarios
MySQL日志
SAP 智能机器人流程自动化(iRPA)解决方案分享
Collation and review of knowledge points of Microcomputer Principle and interface technology - pure manual
玩转gRPC—不同编程语言间通信