@PathVariable handles the case where the parameter is empty

@RequestMapping(value = "/get/{id}/{userId}", method = RequestMethod.GET)
    public Result getMemberShip(@PathVariable("id") int id,@PathVariable("userId") int userId) {

If id is a non-required parameter

 

// You can specify multiple matching paths 

@RequestMapping(value = {"/get/{userId}", "/get/{id}/{userId}"}, method = RequestMethod.GET)


// Then set parameters are not required 

@PathVariable(required = false ) String id

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325157100&siteId=291194637