Spring MVC - Cannot map request parameters as a Map parameter in method?
Posted
by Ken Chen
on Stack Overflow
See other posts from Stack Overflow
or by Ken Chen
Published on 2010-05-22T05:16:56Z
Indexed on
2010/05/22
5:20 UTC
Read the original article
Hit count: 550
spring-mvc
What I want to do is passing a map to the method in Controller using @RequestParam, but it seems not working. While this is working in Struts 2.
Below is what I am trying: In JSP using JQuery: var order = {}; order['seq'] = "ASC"; var criteria = {}; criteria['label'] = "Directory";
$.post(context + 'menu/list',
{"orders" : order,
"criterias" : criteria}
The parameters I am trying to post is an 'map' object order and criteria for listing menu. In Java:
@RequestMapping("/{collection}/list")
public @ResponseBody Map<String, ? extends Object> list(@PathVariable String collection,
@RequestParam("criterias") Map<String, String> criteria,
@RequestParam("orders") Map<String, String> order) {
However, when I print out the map criteria & order in Java, it takes all value as below:
Criteria: {criterias[label]=Directory, orders[seq]=ASC}
Order: {criterias[label]=Directory, orders[seq]=ASC}
Can @RequestParam in Spring be used to init a Map parameter?
© Stack Overflow or respective owner