【发布时间】:2021-05-13 04:49:00
【问题描述】:
您好,我在 springboot 应用程序中传递字符串参数时遇到了一些困难。我使用 Postman 给出一个“名称”参数!每次都说“必需的字符串参数'name'不存在”!
即使我删除了@RequestParam,System.print.out 也会说该值为 null ...
我的产品控制器
@GetMapping("/searchProducts" )
public @ResponseBody Iterable<Product> listSearchedProducts(@RequestParam String name){
System.out.println(name);
return productService.getSearchedProducts(name);
}
【问题讨论】:
-
在邮递员中,您正在发送发布请求,因此请使用@PostMapping,或者更改RequestURL
-
在邮递员中将名称参数放在参数选项卡中,而不是在正文中。您正在尝试使用 json 正文发送获取请求
标签: java spring-boot postman