I have the below spring rest API :
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponsePack getPacks(HttpServletRequest request, @RequestParam(value = "effDate", required = false) String effDate, @RequestParam(value = "cardType", defaultValue = "*") String cardType, @Valid @ModelAttribute Wrapper requestParamWrapper) {
effDate
and cardType
are the two params passed to this API (both are optional).
What I'm trying to do is set a default value of *
to cardType
if nothing is passed.
I can see that the String cardType
has got the correct default value. How do i do something similar for the requestParamWrapper's cardType
(in the model attribute) , i.e setting the default value *
for cardType
when the param is not passed.