Il incapable de fonctionner sur les deux URL http : // localhost: 8080 / SeleniumExécutionTrending / Rapports / DuréeTrend / 427 -> Il n'appelle pas.
HTTP: // localhost: 8080 / SeleniumExécutionTrending / Rapports / DuréeTrend / 427 / 7- - > il exécute. P> Je veux exécuter les deux dans la même méthode p> p>
3 Réponses :
@GetMapping(value= {"/durationtrend/{moduleId}","/durationtrend/{moduleId}/{records}"},produces= MediaType.APPLICATION_JSON_VALUE) public List getExecutionDurationByModuleId(HttpServletRequest request) { Map map= (Map) request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE); Integer moduleId=null,records=null; if(map!=null && map.get("moduleId")!=null){ moduleId = Integer.valueOf(map.get("moduleId").toString()); } if(map!=null && map.get("records")!=null){ records = Integer.valueOf(map.get("records").toString()); } System.out.println("moduleId:"+moduleId); System.out.println("records:"+records); //then you use modules and records , just judge whether they are null? return executionDurationService.getExecutionDuration(moduleId,records); } I tried code above that works . Try it , hopes that help you !
Voici votre problème est
@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); }
Ici, les déclarations System.out.Println à des fins de test ... Cela m'a fonctionné
@GetMapping(value= "/module-execution-trend",produces=MediaType.APPLICATION_JSON_VALUE) public List<ExecutionResource> getExecutionResult(@RequestParam("moduleId") Integer moduleId,@RequestParam(name="records",required=false,defaultValue="10") Integer records ) { System.out.println(moduleId); System.out.println(records); return executionService.getModuleExecutionResult(moduleId,records); }
Je pense que c'est mieux