簡體   English   中英

如何使用 postman 或 feign 客戶端在 Spring 引導中將值設置為 @RequestAttribute

[英]How to set value to @RequestAttribute in Spring boot using postman or feign client

我有這樣的方法:

@PostMapping(path = "/workflow-services/{service_id}/tickets",
  consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
  public ResponseEntity<TicketIdResponse> createTicket(@PathVariable("service_id") String  serviceId,
  @RequestBody @Validated CreateTicketRequest request, @RequestAttribute Payload payload) {
log.info("Start create ticket [{}]", request);

TicketIdResponse response = ticketService.createTicket(serviceId, request, payload);

log.info("Create ticket response: {}", response);
return ResponseFactory.success(response);

}

那么如何在 postman 或假裝客戶端中將值設置為 @RequestAttribute Payload

非常感謝!

@RequestAttribute 注釋通常用於檢索在服務器端但在同一 HTTP 請求期間填充的數據。 例如,如果您使用了攔截器、過濾器或可能的方面來填充“有效負載”屬性,那么您應該能夠使用 @RequestAttribute 注釋來訪問它。

如果您希望從外部客戶端傳遞某些內容(即通過 postman、curl 或任何其他簡單客戶端)-@RequestAttribute 不是前進的方向。

良好的參考; https://www.baeldung.com/whats-new-in-spring-4-3 https://www.logicbig.com/tutorials/spring-framework/spring-web-mvc/request-attribute.ZFCC358EZ3A8D2FCC6A7268FDC7D8D2

這篇SO帖子也可能有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM