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

时间:2013-11-07 05:55:19

标签: 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" ,
    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";
    }

所有东西都运行正常,但它总是返回

error : function(e) {
    alert('Error: ' + e);
}

在火灾中我得到错误:

*"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*

2 个答案:

答案 0 :(得分:0)

List<String> List2= content.getList2();
int counter = 0;
for (String id1: content.getList1()) {

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

答案 1 :(得分:0)

您是否已通过ViewResolver创建并创建了良好的jsp视图?

我认为你很困惑,如果你只想回复“成功”字符串使用HttpServletResponse.getWriter()直接做。