[英]How to send one of the json parameter of a request body through url and rest through body of postman for @Postmapping
I have a class:我有一个 class:
public class SubMdl {
private Integer Id;
@NotEmpty
private String mssd;
private String name;
private String location;
//constructor,getters,setters
}
While doing @Postmapping can we send mssd in the url and rest of the data in the json body in the postman combined? While doing @Postmapping can we send mssd in the url and rest of the data in the json body in the postman combined?
If possible then what will be written in controller class as @RequestBody in the controller will expect whole data and definitely considering @NotEmpty.如果可能,那么将在 controller class 中作为@RequestBody 写入 controller 中的内容将期望完整数据,并且肯定会考虑@NotEmpty。
Is there any solution available?有没有可用的解决方案?
You can send mssd
as PathVariable
or RequestParam
and rest of the parameter as ReqeustBody
as below.您可以将
mssd
作为PathVariable
或RequestParam
以及参数的 rest 作为ReqeustBody
,如下所示。
@PostMapping(value = "/{id}")
public String samplePost(@PathVariable("mssd") String mssd, @RequestBody SubMdlChild payload){
return <your-service-call>;
}
UPDATE: In the RequestBody
, I have taken a sample class name SubMdlChild
which will not contain the mssd
as per your requirement.更新:在
RequestBody
中,我取了一个示例 class 名称SubMdlChild
根据您的要求不包含mssd
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.