0


利用postman完成JSON串的发送功能(springboot)

postman简介: postman工具是用来做网络接口测试的,用它来模拟网络请求,上传数据,然后得到后台项目返回的响应。Postman可以模拟表单提交,也能模拟Ajax请求,测试网络接口变得非常容易。

第一步,代码分析

@RequestMapping("/query")// 可用于Get或Post请求@ResponseBody// 将java对象转为json格式的数据// 使用 Map<String,Object> 对象接收前端传递的参数,前端传过来一个字符串,然后放到Map中,publicMap<String,Object>query(@RequestBody(required =false)Map<String,Object> requestMap){return requestMap;}

第二步,打开IDEA,执行程序后查看端口号为8080(http)。
在这里插入图片描述

第三步,打开postman,初始界面如下。
在这里插入图片描述

第四步,点击postman上方的➕,新建一个postman数据传输的操作界面,选择Body-raw-JSON,然后在输入框内输入内容,点击send后,可以发现输入什么传出什么。
接口的URL地址组成:http://127.0.0.1:端口号/控制器/方法。
在这里插入图片描述

相关链接:
IntelliJ IDEA中构建Spring Boot的项目
Spring Boot中的配置文件(application.properties、application.yml与pom.xml)
ORM、JPA、Spring Data JPA和常用的五种访问数据库方式

SpringBoot–页面显示列表功能
SpringBoot–列表添加详情功能
SpringBoot–列表添加新增功能
SpringBoot–列表更新功能
SpringBoot–列表删除功能

SpringBoot的控制层注解(@Controller与@RestController)
SpringBoot的业务层注解(@Resource、@Autowired与@Qualifier)
SpringBoot的映射(@RequestMapping、@GetMapping与@PostMapping)
SpringBoot的函数参数(JavaBean对象、@RequestParam与@RequestBody)
SpringBoot的返回数据(@ResponseBody、返回templates下的网页 与 返回公共网页)

利用postman完成JSON串的发送功能(springboot)
利用postman完成数据的分页查询功能(springboot)
利用postman完成向数据库中添加数据的功能(springboot)

Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
Preparing: insert into user(uuid,username,gender,age,phone,address) values(?,?,?,?,?,?,?)
Could not autowire. No beans of ‘UserMapper‘ type found.
Error starting ApplicationContext. To display the conditions report re-run your application with
Loading class com.mysql.jdbc.Driver‘. This is deprecated. The new driver class is com.mysql.cj.jdb
Plugin ‘org.springframework.boot:spring-boot-maven-plugin:‘ not found
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
This application has no explicit mapping for /error, so you are seeing this as a fallback.
BootStrap-SpringBoot的使用过程中前端table表格无法加载出数据。


本文转载自: https://blog.csdn.net/blbyu/article/details/126533207
版权归原作者 慕斯-ing 所有, 如有侵权,请联系我们删除。

“利用postman完成JSON串的发送功能(springboot)”的评论:

还没有评论