繁体   English   中英

如何通过 url 和 Z65E8800B5C6800AAD8800B5C6800AAD8800B5C6800AAD896F888B2A62AFCZ 的主体发送请求主体的 json 参数之一为@FCBmapping80AFD3511Z5

[英]How to send one of the json parameter of a request body through url and rest through body of postman for @Postmapping

我有一个 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?

如果可能,那么将在 controller class 中作为@RequestBody 写入 controller 中的内容将期望完整数据,并且肯定会考虑@NotEmpty。

有没有可用的解决方案?

您可以将mssd作为PathVariableRequestParam以及参数的 rest 作为ReqeustBody ,如下所示。

@PostMapping(value = "/{id}")
    public String samplePost(@PathVariable("mssd") String mssd, @RequestBody SubMdlChild payload){
       return <your-service-call>;
    }

更新:RequestBody中,我取了一个示例 class 名称SubMdlChild根据您的要求不包含mssd

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM