springboot的get请求和post请求

get请求

直接传参数

http://localhost:8081/us/123

	@RequestMapping("/us/{id}")
	@ResponseBody
	public String submitForm(@PathVariable(value = "id") String id) {
		System.out.println("str=" + id);
		return "提交成功";
	}

使用?拼接传参

http://localhost:8081/us?name=nazha&age=18

	@RequestMapping("/us")
	@ResponseBody
	public String submitForm(@RequestParam(value = "name") String name
			, @RequestParam(value = "age")Integer age ) {
		System.out.println("str=" + name);
		System.out.println("age=" + age);
		return "提交成功";
	}

SpringMVC接收Get请求参数

post请求

public String FFmpeg(@RequestBody Commands commands)
//会自动将json转化为Commands,一定要11对应

springmvc接收json数据的4种方式

spring mvc中post、get方法获取参数的几种方式

原文地址:https://www.cnblogs.com/psyduck/p/14120161.html