![](/img/trans.png)
[英]log request body string in RestController ExceptionHandler
[英]RestController fill automatically request body and headers
我們有 RestController 端點,它們在正文中接收參數,也從頭文件中接收參數
所以我們創建了 RequestVO 對象,它會自動填充 JSON(/XML) 參數
@PostMapping
public @ResponseBody ResponseEntity<String> endpoint(@RequestBody RequestVO requestVO, HttpServletRequest httpRequest) {
但是對於請求/標頭的參數,我們必須使用 setter 來填充值
有沒有辦法用標頭/請求參數自動填充對象?
如果我理解正確,你可以使用這樣的東西
@RequestHeader(value="Key") String value,
@RequestHeader(value="Content-Type") String contentType,
...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.