Send the parameters to server(spring framework) via get request, i am thinking of making a json object of all those parameters and send in get request so that in java spring i can recieve at as a map at the controller class in spring , how to achieve this I am new to spring please help me out
I so far tried to send those parameters singly like(pram1,param2,param3,param4) and recieve at the server side as string by setting param to string in type script before making get request to the server->i recieved parameters as map in controller but i dont think it is a best way
{
param1: "param1"
param2: "param2
paramn: "paramn"
}
Send the above to the server in the controller class ↓
@RequestParam MultiValueMap<String, String> requestMap
I want to receive parameters as
String param1= requestMap.get("param1");
String param2=requestMap.get("param2");
If the map type were an object, it would be great so that I can receive any kind of object
example
at client side i am sending {param1: "myName", id: 0001}
at server side requestMap.get("param1"); requestMap.get("id");
if you specify RequestParam as hashmap, it gets automatically converted from json by jackson. Alternatively, if you are using String as the param, you can use ObjectMapper to convert it to a Map and get values from there.