弹簧座控制器POST请求不存在';不能使用Ajax Json数组负载

弹簧座控制器POST请求不存在';不能使用Ajax Json数组负载,json,ajax,spring-mvc,Json,Ajax,Spring Mvc,我在使用json负载发送post请求时收到404 not found错误。在后端,我使用SpringREST控制器 请在下面查找代码 @RequestMapping(value = "/api/testEnvironment/update", method = RequestMethod.POST , consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?> updateEnvironment(@Req

我在使用json负载发送post请求时收到404 not found错误。在后端,我使用SpringREST控制器

请在下面查找代码

@RequestMapping(value = "/api/testEnvironment/update", method = RequestMethod.POST , consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> updateEnvironment(@RequestParam("ids") String[] ids, @RequestParam("name") String name) {
    System.out.println(ids);

    return new ResponseEntity<>(HttpStatus.OK);
}

ajax
调用
url
时,似乎缺少开头的
/
,请尝试
“/api/testEnvironment/update”
,这可能是我的打字错误,但我确信它与url无关。问题与json有效负载和rest控制器有关
 function testing(){
        var a = [] ;
        a.push('a');
        a.push('b');
        var b = '23';

         var search = {
                 "ids" : a,
                 "name" : b
        }

$.ajax({
            type : "POST",
            url : "api/testEnvironment/update",
            contentType: "application/json",
            data: JSON.stringify(search),
            traditional: true,
            success : function(data) {

            },
            error : function(e) {

            }
        });
   }