Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.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

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
当控制器获取正确数据时,对spring控制器的jQuery Ajax调用返回错误方法_Jquery_Ajax_Spring - Fatal编程技术网

当控制器获取正确数据时,对spring控制器的jQuery Ajax调用返回错误方法

当控制器获取正确数据时,对spring控制器的jQuery Ajax调用返回错误方法,jquery,ajax,spring,Jquery,Ajax,Spring,我有一个jQuery ajax调用,如下所示: $("tr." + trClassName).each(function() { list1.push(some Id from td); list2.push(some id from another td); }); //这里list1和list2类似于{1,2,3,4,…} $.ajax({ type : "GET", url : "./bulkUpdate" ,

我有一个jQuery ajax调用,如下所示:

  $("tr." + trClassName).each(function() {                
     list1.push(some Id from td);
     list2.push(some id from another td);
});
//这里list1list2类似于{1,2,3,4,…}

$.ajax({
    type : "GET",
    url : "./bulkUpdate" ,
    data : "id=" + id + "&list1=" +list1+ "&list2=" + list2,
    success : function(response) {
        alert("Dispaly orders updated successfully");
    },
    error : function(e) {
        alert('Error: ' + e);
    }
});
现在在控制器中,我的接收器代码为:

   @RequestMapping(value = "/bulkUpdate", method = RequestMethod.GET)
   public @ResponseBody String updateOrders(@ModelAttribute(value = "content") Content content) {

       // **Content** class has attributes for **list1** and **list2**
       // here i am getting the correct data like:

       List<String> list1= content.getList1();
       List<String> list2= content.getList2();

       /* do something */

       return "success";
    }
在fire bug中,我得到的错误如下:

*"NetworkError: 404 Not Found - http://localhost:8080/web-pack/tool/languageTool/bulkUpdate?id=1&list1=8,9,10,11,13,105,129,132,12,135,134&list2=8,9,10,11,14,15,16,17,18,19,20*
List List2=content.getList2();
int计数器=0;
for(字符串id1:content.getList1()){
sysout(id1+List2.get(计数器));
柜台++
}

您的ViewResolver是否已经创建并加载了success.jsp视图


我认为您很困惑,如果您只想响应“success”字符串,请直接使用HttpServletResponse.getWriter()执行操作。

如何确保控制器成功完成请求?我相信您正在将
list1
list2
作为
String
而不是
List
@GGG发送。我正在调试代码,并在控制器中给出正确的值。请在我的新答案部分查看控制器中的代码。我忘了在控制器的返回类型中添加@ResponseBody标记,它与HttpServletResponse.getWriter()的工作方式相同。。。这是正确的观点,只是犯了一个小错误。。太多了
*"NetworkError: 404 Not Found - http://localhost:8080/web-pack/tool/languageTool/bulkUpdate?id=1&list1=8,9,10,11,13,105,129,132,12,135,134&list2=8,9,10,11,14,15,16,17,18,19,20*
List<String> List2= content.getList2();
int counter = 0;
for (String id1: content.getList1()) {

  sysout(id1 + List2.get(counter));
  counter ++
}