Jquery调用Spring MVC控制器方法

时间:2011-12-27 20:20:34

标签: jquery ajax spring model-view-controller list

我需要通过JQuery ajax调用我的Spring MVC控制器的方法。

这是我方法的定义:

@Controller
public class UserController {

@RequestMapping(value = "/saveUserColumnSetting")
   @ResponseBody
   public String saveUserColumnSetting(HttpServletRequest request,
       List<UserInboxColumnSetting> userInboxColumnSettings, int
pageItemCount) {
...
}

而是javascript代码是:

var json = [{"id":0,"createUser":null,"updateUser":null,"createTime":null,"updateTime":null,"columnName":null,"columnOrder":0,"columnSize":0,"show":false,"inboxColumnSetting":null},{"id":0,"createUser":null,"updateUser":null,"createTime":null,"updateTime":null,"columnName":null,"columnOrder":0,"columnSize":0,"show":false,"inboxColumnSetting":null}];

$.ajax({
       url: ctx + "/saveUserColumnSetting",
               data: ({userInboxColumnSettings : json,pageItemCount : 3}),
               success: function(data) {
               $("#saveUserColumnSetting").html(data);
       },
       error: function (jqXHR, textStatus, errorThrown) {
               alert(jqXHR + " : " + textStatus + " : " + errorThrown);
       }
     });

但我从服务器收到“未找到错误”。我的问题是:如何将带有JQuery ajax的对象列表传递给我的Spring MVC控制器。提前谢谢。

0 个答案:

没有答案