当前位置:网站首页>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];
}
}
边栏推荐
- How will the surging tide of digitalization overturn the future?
- C language ordering management system
- 2022年PMP项目管理考试敏捷知识点(6)
- Uni app realizes advertisement scroll bar
- 被裁三個月,面試到處碰壁,心態已經開始崩了
- 【 剑指 Offer】55 - I. 二叉树的深度
- 使用 Lambda 函数URL + CloudFront 实现S3镜像回源
- 龙蜥社区开源 coolbpf,BPF 程序开发效率提升百倍
- ArrayList扩容机制以及线程安全性
- 用命令行 给 apk 签名
猜你喜欢

Interpretation of R & D effectiveness measurement framework

陈宇(Aqua)-安全-&gt;云安全-&gt;多云安全

Chen Yu (Aqua) - Safety - & gt; Cloud Security - & gt; Multicloud security

04 redis source code data structure dictionary

Six years of technology iteration, challenges and exploration of Alibaba's globalization and compliance

使用net core 6 c# 的 NPOI 包,读取excel..xlsx单元格内的图片,并存储到指定服务器

App automation testing Kaiyuan platform appium runner

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

Etcd 概要 机制 和使用场景

用栈实现队列、用队列实现栈(C语言_leetcode_232+225)
随机推荐
学会使用LiveData和ViewModel,我相信会让你在写业务时变得轻松
Simplex, half duplex, full duplex, TDD and FDD
那个很努力的学生,高考失败了……别慌!你还有一次逆袭机会!
MySQL日志
Learning to use livedata and ViewModel will make it easier for you to write business
How much money do novices prepare to play futures? Is agricultural products OK?
使用CMD修复和恢复病毒感染文件
SAP 智能机器人流程自动化(iRPA)解决方案分享
20个实用的 TypeScript 单行代码汇总
Sign APK with command line
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)
Error:Kotlin: Module was compiled with an incompatible version of Kotlin. The binary version of its
小程序-小程序图表库(F2图表库)
Benefiting from the Internet, the scientific and technological performance of overseas exchange volume has returned to high growth
Basic operation of queue (implemented in C language)
C language ordering management system
【Flask】Flask启程与实现一个基于Flask的最小应用程序
ArrayList capacity expansion mechanism and thread safety
Use the npoi package of net core 6 C to read excel Pictures in xlsx cells and stored to the specified server
Summary of 20 practical typescript single line codes