Skip to content
Advertisement

How to get value of query param array in spring boot?

I have this URL

http://127.0.0.1:3009/mac/view/:userId?ot-replace[0]=kin43

I need the value of ot-replace[0]

In the controller I am using

 @RequestParam(name="ot-replace", required=false)String[] regexReplace

Also tried using

 @RequestParam(name="ot-replace", required=false)List<String> regexReplace

I always get null. Not sure what is the issue here

Advertisement

Answer

Your URL should like this.

http://127.0.0.1:3009/mac/view/:userId?ot-replace=kin43,value2,vlue3

then you can get a String[].

ot-replace[0]=kin43
ot-replace[1]=value2
ot-replace[2]=value3
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement