Übergeben einer Map <String, String> an einen springMVC-Controller
Ich versuche, eine HashMap oder eine andere Map-Implementierung von Ajax an einen Spring MVC-Controller zu senden
Hier ist das Detail, wie ich es mache:
Der Ajax-Aufruf lautet wie folgt
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);
}
});
dann auf der Controllerseite habe ich:
@RequestMapping(value="/publisher/doTestMap.do", method=RequestMethod.POST)
public @ResponseBody String doTestMap(@RequestParam(value = "tags", defaultValue = "") HashMap<String,String> tags, HttpServletRequest request) { //
System.out.println(tags);
return "cool";
}
Leider bekomme ich systematisch
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
Was mache ich falsch ?
Vielen Dank.