这是返回415媒体类型未找到错误的jquery函数
$('#save').on('click',function(){
alert("test");
var data = JSON.stringify(jQuery('#form').serializeArray());
console.log("data"+data);
$.ajax({
type: "POST",
url: "saveExpenses",
data: JSON.stringify(jQuery('#form').serializeArray()),
contentType: "application/json; charset=utf-8",
dataType: "json",
cache: true,
success: function(data){alert("Success");}
})
})
和控制器:
@RequestMapping(value="/saveExpenses",method=RequestMethod.POST)
public String saveExpense(@RequestBody 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";
}
答案 0 :(得分:0)
也许你应该看一下制作和使用注释和属性。 这些帖子肯定会有所帮助:
或者我没理解......
编辑: