here your problem is
@PathVariable("moduleId") Integer moduleId,@PathVariable("records") Integer records
you need moduleId and records parameters for both your URL, in the first URL "/durationtrend/{moduleId}"
you did not have records parameter that's why you have
org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.resolveException
Resolved [org.springframework.web.bind.MissingPathVariableException:
Missing URI template variable 'records' for method parameter of type
Integer]
this error
Actually, you can achieve this goal in many ways, like using HttpServletRequest and other things, but remember you are using spring and you need to simplify the things using spring framework.
the simple way which I suggest is using two separate controllers and simplify the things.
@GetMapping("/durationtrend/{moduleId}")
public void getExecutionDurationByModuleId(@PathVariable("moduleId") Integer moduleId) {
return executionDurationService.getExecutionDuration(moduleId);
System.out.println(moduleId);
}
@GetMapping("/durationtrend/{moduleId}/{records}")
public void getExecutionDurationByRecords(@PathVariable("moduleId") Integer moduleId, @PathVariable("records") Integer records) {
return executionDurationService.getExecutionDuration(moduleId, records);
System.out.println(moduleId);
System.out.println(records);
}
this is easy to understand and you can create getExecutionDuration(moduleId) method in your service class and can easily bypass it...
hope it is helpful...