G
G
grv12017-08-21 18:44:40
Spring
grv1, 2017-08-21 18:44:40

How to pass json object as get parameter?

I'm trying to pass json in a get request, it fails, apparently some type of data is needed that is not HashMap
http://localhost:8080/mesure/create?values={test: "test"}

@RequestMapping(value = "/create")
    public void setMesureId(@RequestParam(value = "values", required = false) HashMap<String, String> profileJson) {
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
i_visseri, 2017-08-21
@i_visseri

GET -request involves getting data. If you need to send data, then do it using the POST method .

A
Alexander Kosarev, 2017-08-21
@jaxtr

First, we need to serialize the transmitted data using URLEncode.
Secondly, you will need a converter that can turn the string into a HashMap.
in general, as i_visseri said , if you need to transfer some kind of payload, it is better to use POST requests.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question