jeudi 16 juillet 2015

Retriving map-like key-key-value from POST request

I've been used to do this in PHP where I can do like this in HTML:

<input name="a[b][c]" value="abc">
<input name="a[b][d]" value="def">
<input name="a[d][y]" value="nope">

Then get it in PHP e.g. as:

foreach($_POST['a']['b'] as $thisId => $value){
    echo "key: $thisId, value: $value\n";
}

Which outputs:

key: c, value: abc
key: d, value: def

I've tried to find but I can't seem to be able to find an equivalent in the default javaEE. How can I get the equivalent with plain javaEE (without me doing the code itself)?
If it doesn't exist, is there a library that does that job?

Edit: To add up to what sᴜʀᴇsʜ ᴀᴛᴛᴀ mentions, I do not want the list of everything that I get in the request... I added another element in the example above to try to make it more clear.

Aucun commentaire:

Enregistrer un commentaire