Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

jquery - Passing hashmap from javascript to servlet

I created a simplehashmap using the accepted solution in this question: How to create a simple map using JavaScript/JQuery

I however need to send this var to a servlet and retrieve them onto a Java HashMap. How do I do that.

The key is a string while the value is an array, say like:

`[1,'apple,orange, banana'],[2,'apple,peach, banana']` ...

I need the keys 1,2 and the array loaded onto a Java HashMap.

I tried to post it using jquery. where selectedrows is my map

$.post(url, { id: selectedrows });
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I creates a JSON string and then sent it via an ajax post to the servlet and build the HashMap there.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...