package springboot.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import springboot.service.IService;
@RestController
public class HelloController {
@Autowired
private IService iService;
@PostMapping("hello")
public String hello(@RequestBody JSONArray jsonArray){
System.out.println(jsonArray);
return "jsonArray "+jsonArray;
}
@PostMapping("hello1")
public String hello1(@RequestBody JSONObject jsonObejct){
System.out.println(jsonObejct);
return "jsonObejct="+jsonObejct;
}
@GetMapping("test")
public String test(){
iService.testAsync();
return "调用接口返回";
}
}
SpringBoot中JSONObject 和 JSONArray的请求解析
最新推荐文章于 2023-06-07 20:34:45 发布