Reputation: 333
I have the following spring-boot REST Controller:
@RestController
@AllArgsConstructor
public class AuditRecordArchivalHistoryController {
private final AuditRecordArchivalHistoryService auditRecordArchivalHistoryService;
@RequestMapping(value = "/archives", params = "pageNumber")
public Mono<Slice<AuditRecordArchivalHistory>> findRecordsForAllTenants(
@RequestParam (defaultValue = "0") Integer pageNumber)
return
auditRecordArchivalHistoryService.findAllAuditRecordArchivalHistoryRecords(
getPageable(pageNumber)
);
}
@RequestMapping(value = "/archives", params = {"tenantId, pageNumber"} )
public Mono<Slice<AuditRecordArchivalHistory>> findRecordsForTenant(
@RequestParam String tenantId,
@RequestParam Integer pageNumber) {
return
auditRecordArchivalHistoryService.findAuditRecordArchivalHistoryByTenantId(
tenantId, getPageable(pageNumber)
);
}
I expect that if I access the URL
/archives?pageNumber=1
the method: findRecordForAllTenants() would be called.
Whereas my expectation upon accessing the URL
/archives?tenantId=abc&pageNumber=1
is that the method: findRecordsForTenant() would be called.
However, in both the cases, the method findRecordsForAllTenants() is being called. Am I missing something?
Upvotes: 1
Views: 1788
Reputation: 54
You have put "tenantId, pageNumber", it should be "tenantId", "pageNumber". You are missing quotes.
Upvotes: 1
Reputation: 46
I think this problem is because the parameters in params are written wrong, you can compare to what I wrote below.
@RequestMapping(value = "/archives", params = {"tenantId", "pageNumber"} )
public Mono<Slice<AuditRecordArchivalHistory>> findRecordsForTenant(
@RequestParam String tenantId,
@RequestParam Integer pageNumber) {
return auditRecordArchivalHistoryService.findAuditRecordArchivalHistoryByTenantId(
tenantId, getPageable(pageNumber));
}
Upvotes: 3
Reputation: 77
Mast be like:
@RequestMapping(value = "/archives")
public Mono<Slice<AuditRecordArchivalHistory>> findRecordsForAllTenants(
@RequestParam (name="pageNumber", defaultValue = "0") Integer pageNumber)
return
auditRecordArchivalHistoryService.findAllAuditRecordArchivalHistoryRecords(
getPageable(pageNumber)
);
Upvotes: -1