我试图将表单数据从ajax jquery发送到java控制器但是得到400错误

时间:2017-10-17 17:27:53

标签: javascript java jquery ajax

我在console.log中获取表单数据

$('#save').on('click',function(){
alert("test");
var data = $('form').serialize();
console.log("data"+data);
$.ajax({
    type: "POST",
    url: "saveExpenses",
    data: $('form').serialize(),
    cache: true,
    success: function(data){
        alert("Success");
    }
  })
})

和控制器:

@RequestMapping(value="/saveExpenses",method=RequestMethod.POST)
public String saveExpense(ExpensesSummary expenses, HttpServletRequest request,HttpSession session){
    System.out.println("first name"+expenses.getFirstName());
    String message = homeBankingDao.expenseSummary(expenses);
    request.getSession().setAttribute("message",message);
    return "login";

}

但是我得到了400个错误请求错误。任何人都可以帮助我...

0 个答案:

没有答案