我有這樣一個端點,我想用它來獲取頁面資料:
我有這樣一個端點,我想用它來獲取頁面資料。
@RequestMapping(method = RequestMethod. GET, value = "/task", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity< ? > processTask(@Valid TaskSearchParams params, Pageable pageable)
{
.....
return new ResponseEntity<>(....., HttpStatus.OK) 。
}
Search Prams DTO:
@Getter。
@Setter
public class TaskSearchParams {
private String title;
private String status;
}
我需要為TaskSearchParams和Pageable發送什么有效載荷?我試過:
{<
"size": 1,
"pageNumber": 1,
"offset": 1,
"sort": "desc"
}
但是我不確定我需要包括TaskSearchParams。
uj5u.com熱心網友回復:
如果這些是路徑變數,你應該用大括號把它們括起來,并用@PathVariable來注釋變數
@RequestMapping(method = RequestMethod. GET, value = "/task/{title}/{status}" , produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity< ? >。processTask(@Valid @PathVariable String title。@PathVariable String status,Pageable pageable)
{
.....
return new ResponseEntity<>(....., HttpStatus.OK) 。
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/309956.html
標籤:
