方法参数类型String[]的所需请求参数不存在



我正在尝试从查询参数中读取数组值,该参数传递为

ot-replace[0]=kin43

控制器上有

@GetMapping(value = "/{userId}/**")
public ResponseEntity<String> viewObject(@PathVariable(value = "userId") String uid, 
@RequestParam(name="ot-replace")String[] regexReplace){}

我得到以下错误

"trace": "org.springframework.web.bind.MissingServletRequestParameterException: Required request parameter 'ot-replace' for method parameter type String[] is not presentrntat org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.handleMissingValueInternal(RequestParamMethodArgumentResolver.java:218)rntat org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.handleMissingValue(RequestParamMethodArgumentResolver.java:193)rntat org.springframework.web.

将ot-replace[0]=kin43改为ot-replace=kin43&ot-replace=kin44您将在数组中得到两个元素。

最新更新