Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring将映射作为请求参数传递_Java_Ajax_Spring_Post_Httprequest - Fatal编程技术网

Java Spring将映射作为请求参数传递

Java Spring将映射作为请求参数传递,java,ajax,spring,post,httprequest,Java,Ajax,Spring,Post,Httprequest,我想将贴图对象作为参数传递给spring控制器 我的ajax请求: $.ajax({ type : 'POST', url : '/create', contentType : 'application/json; charset=UTF-8', data : JSON.stringify({ pk : 111, params : {

我想将贴图对象作为参数传递给spring控制器

我的ajax请求:

$.ajax({
            type : 'POST',
            url : '/create',
            contentType : 'application/json; charset=UTF-8',
            data : JSON.stringify({
                pk : 111,
                params : {
                    param1 : 'someValue',
                    param2 : 'anotherValue'
                }
            })
        });
我的请求处理程序:

@RequestMapping(value = "/create", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody CrudActionResponse postCreate(HttpSession session,
        @RequestParam(value = "params") Map<String, String> values, Integer pk)
{
    ...
}

您似乎想要发送JSON内容。将
@RequestBody
与适当的数据类型一起使用。首先,我尝试将其发送到url编码,但这也不起作用。如果要发送JSON,请在正文中发送。这就是我想说的。你能举个例子吗?只要查一下,你会发现很多。
 org.springframework.web.bind.MissingServletRequestParameterException: Required Map parameter 'params' is not present