package com.example.demomap.Controller; import com.example.demomap.pojo.ParaEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest;
import java.util.Map; @RestController
public class DemoCotroller { /**
* POSTMAN配置:
* Headers----------[{"key":"Content-Type","value":"application/json",}]
* <p>
* 形式一: form_data: id : 123 name : ego
* <p>
* 形式二: raw {"id":"1213","name":"wqwq"} JSON(application/json)
*/ @RequestMapping("/demoRequest")
public void demofind(HttpServletRequest request) {
System.out.println(request.getParameter("id")); /**
*
*输出结果 : 形式一: form_data 输出:123
* 形式二: raw 输出:null
*/
} @RequestMapping("/demoId")
public void demofind4(@RequestParam String id) { System.out.println(id);
/**
*
*输出结果 : 形式一: form_data 输出:123
* 形式二: raw 输出: [nio-8080-exec-6] .w.s.m.s.DefaultHandlerExceptionResolver
*/
} @RequestMapping("/map")
public void demofind45(@RequestBody Map<String, String> map) { System.out.println(map.get("id"));
/**
*
*输出结果 : 形式一: form_data 输出:"timestamp": "2019-03-26T09:00:39.157+0000",
* "status": 415,
* "error": "Unsupported Media Type",
* "message": "Content type 'multipart/form-data;boundary=--------------------------814844782807228889080332;charset=UTF-8' not supported",
* "path": "/map"
*
* 形式二: raw 输出:1213
*/
} @RequestMapping("/entity")
public void demofind456(ParaEntity paraEntity) { // ParaEntity自定义封装的实体 System.out.println(paraEntity.getId());
/**
*
*输出结果 : 形式一: form_data 输出:123
* 形式二: raw 输出:null
*/
} }