Issue
I am trying to read an array value from query param which is passes as
ot-replace[0]=kin43
On the controller I have
@GetMapping(value = "/{userId}/**")
public ResponseEntity<String> viewObject(@PathVariable(value = "userId") String uid,
@RequestParam(name="ot-replace")String[] regexReplace){}
I get the following error
"trace": "org.springframework.web.bind.MissingServletRequestParameterException: Required request parameter 'ot-replace' for method parameter type String[] is not present\r\n\tat org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.handleMissingValueInternal(RequestParamMethodArgumentResolver.java:218)\r\n\tat org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.handleMissingValue(RequestParamMethodArgumentResolver.java:193)\r\n\tat org.springframework.web.
Solution
instead of ot-replace[0]=kin43 replace with ot-replace=kin43&ot-replace=kin44 You will get two item in your array.
Answered By - sjy
Answer Checked By - David Marino (JavaFixing Volunteer)