Q:

How to provide default values for array parameters in spring MVC url mapping? 

@RequestMapping(value = "/getUserScoreCardDetails", method = RequestMethod. GET)
public @ResponseBody List<ScoreDetails> getUserScoreCardDetails(
@RequestParam(value = "playerIds", required = false) int[] playerIds) { 

}

I need to provide default values [1,2,3] for playerIds if playerIds is not available in request? 

A:

You can set comma separated values inside defaultValue property in @RequestParam
@RequestMapping(value = "/getUserScoreCardDetails", method = RequestMethod. GET)
public @ResponseBody List<ScoreDetails> getUserScoreCardDetails(
@RequestParam(value = "playerIds", required = false, defaultValue="1,2,3") int[] playerIds) { 

}

