java restful controller

2023-01-06  本文已影响0人  寻找无名的特质

使用Spring boot MVC创建restful controller。
1、声明为@RestController
2、映射控制器路径 @RequestMapping("/group")
3、在方法上映射方法路径 @RequestMapping(value = "/creategroup", method = RequestMethod.POST)
4、使用@RequestBody声明DTO参数,参数为json对象:
public CreateGroupResultDto restfulTest2(@RequestBody CreateGroupDto dto)
如果使用PostMan进行测试,需要在Body中填写json对象,并将传输类型设置为json。

上一篇下一篇

猜你喜欢

热点阅读