Friday 4 November 2016

Missing URI template variable - Spring MVC issue - Troubleshoot

{
  "timestamp": 1478261692885,
  "status": 500,
  "error": "Internal Server Error",
  "exception": "org.springframework.web.bind.MissingPathVariableException",
  "message": "Missing URI template variable 'id' for method parameter of type String",
  "path": "/admin/3"
}


@RestController
public class ApiAdminController {

    @RequestMapping(name = "/admin/{id}", method = RequestMethod.GET)
    public ResponseEntity<Set<Object[]>> getPermissions(@PathVariable String id){
                .......
                .......
                }
}

Solution : Change name to value in @RequestMapping

@RestController
public class ApiAdminController {

    @RequestMapping(value = "/admin/{id}", method = RequestMethod.GET)
    public ResponseEntity<Set<Object[]>> getPermissions(@PathVariable String id){
                .......
                .......
                }
}


No comments:

Post a Comment