簡體   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