我试图从ajax发送HashMap或任何其他Map实现到
Spring MVC控制器
这是我如何做的细节:
Ajax调用如下
var tags = {};
tags["foo"] = "bar";
tags["whee"] = "whizzz";
$.post("doTestMap.do",{"tags" : tags },function(data,textStatus,jqXHR) {
if (textStatus == 'success') {
//handle success
console.log("doTest returned " + data);
} else {
console.err("doTest returned " + data);
}
});
然后在控制器方面我有:
@RequestMapping(value="/publisher/doTestMap.do",method=RequestMethod.POST)
public @ResponseBody String doTestMap(@RequestParam(value = "tags",defaultValue = "") HashMap tags,HttpServletRequest request) { //
System.out.println(tags);
return "cool";
}
不幸的是我系统地得到了
org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type 'java.lang.String' to required type 'java.util.Map'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [java.util.Map]: no matching editors or conversion strategy found
我究竟做错了什么 ?
谢谢.