通过serialize()方法得到的值为username=xxx&password=xxx
$('#submit').click(function(){
var data = $("form").serialize(); // 表单序列化
$.ajax( {
type : 'POST',url : '/admin/login',data : data,success : function(msg) {
alert(msg);
}
});
});
后台映射方法通过HttpServletRequest 获取值
@RequestMapping(value = "/login",method = RequestMethod.POST)
@ResponseBody
public String login(HttpServletRequest request) {
String username = request.getParameter("username");
String password = request.getParameter("password");
}
原文链接:https://www.f2er.com/ajax/160350.html