我们在使用Intellij Idea开发restful项目的时候,我们可以用idea工具自带的rest client工具进行测试restful数据正确性,我这里简单说下以POST方式+requestBoy的text文档进行restful的测试的数据填充。
我使用的是Spring mvc框架,例如在springmvc中有如下代码
@RequestMapping(value = "/user/getAllUserInfo",method = RequestMethod.POST) public PageInfo<User> getAllUserInfo(@RequestParam(value = "pageNum") Integer pageNum,@RequestParam(value = "pageSize") Integer pageSize, @RequestBody User user){ if(pageNum == null){ pageNum = 1; } if(pageSize == null){ pageSize = 10; } //获取第1页,10条内容,默认查询总数 count PageHelper.startPage(pageNum,pageSize); List<User> userList = userDAO.getAllUserInfo(user); PageInfo<User> pageInfo = new PageInfo<User>(userList); return pageInfo; }
这里使用的是mybatis的PageHelper包。
在使用rest client的时候text的编写内容是以json格式编写的,格式如下:
{"userName":"test2","loginName":"test2", "password":"12345678", "currentUserId":1,"userType":"01" }
同时需要在Headrs里面加上Content-Type=application/json;charset=UTF-8,
如截图所示:
这个就是大概的使用。
相关推荐
丢掉 Postman ! 我选择了 IDEA REST Client
IntelliJ IDEA 自带的高能神器比Postman更加优秀、方便和全面,强烈...但是当使用了 IDEA REST 之后,postman 就可以丢了,因为,IDEA REST Client 具有 postman 的所有功能,而且还有postman 没有的功能,继续往下看。
主要介绍了学会IDEA REST Client后就可以丢掉postman了,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
rest client全套封装好的java调用elasticsearch功能的工程demo,亲测可用。我安装的es是elasticsearch-7.10.0版本,测试好用。直接用idea打开工程就可以使用,并且有写好的junit测试类,可供测试。可以直接拿来做应用...
需要maven开发环境,使用intellij idea打开,分为服务端(server)和客户端(client)
进入sbt交互终端运行run,用advance rest client向 发送一个post请求,内容为{"id":1,"from":{"owner":"yy","balance":100.0},"to":{"owner":"xx","balance":100.0},"amount":50.0} 即可从服务端接收到相应的响应...
1. 因本项目使用了 **lombok** 进行开发,在开发之前需要安装插件,若使用的是 **IDEA** 进行开发,请自行搜索并安装 **lombok** 插件,否则会导致编译错误 2. 若是进行二次开发,请替换 `keystore.jks` **(非常...
Chapter 6 presents the idea behind web services by reviewing REST and the Atom Publishing Protocol. Chapter 7 describes how to use a templating engine such as Kid to generate web pages dynamically. ...
请访问下一个文档二手技术后端: Sprint BootPostgreSQL SQL org.json 昂首阔步Mapstruct 弹性标记前端: Vue JS Vue路由器威化Vue ChartJS 威克斯Axios由Intellij IDEA提供支持
Contents Overview 1 Lesson 1: Concepts – Locks and Lock Manager 3 Lesson 2: Concepts – Batch and Transaction 31 Lesson 3: Concepts – Locks and Applications 51 Lesson 4: Information Collection and ...