前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Springboot @RequestBody 传递 List

Springboot @RequestBody 传递 List

作者头像
netkiller old
发布2018-03-06 10:43:35
9.7K0
发布2018-03-06 10:43:35
举报
文章被收录于专栏:NetkillerNetkiller
本文节选自电子书《Netkiller Java 手札》
6.1.4.1. @RequestBody 传递 List
代码语言:javascript
复制
			package cn.netkiller.api.restful;

import java.util.List;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestRestController {

	@RequestMapping(value = "/test/list/{siteId}", method = RequestMethod.POST)
	public List<String> ping(@PathVariable("siteId") int siteId, @RequestBody List<String> tags) {
		System.out.println(String.format("%d, %s", siteId, tags));
		return (tags);
	}

}			
代码语言:javascript
复制
			$ curl -H "Content-Type: application/json" -X POST -d '["Neo","Netkiller"]' http://localhost:8440/test/list/22.json 

["Neo","Netkiller"]	
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2017-11-07,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Netkiller 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 本文节选自电子书《Netkiller Java 手札》
  • 6.1.4.1. @RequestBody 传递 List
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档