我有一个 jquery ajax 请求
$('#updateUser').live( 'click', function() {
var euserId = editeduserId;
var pname = $('#euname').val();
var psurname = $('#eusurname').val();
var plogin = $('#eulogin').val();
var ppassword = $('#eupassword').val();
var pemail = $('#euemail').val();
var user = {name: pname,
surname: psurname,
login: plogin,
password: ppassword,
email: pemail};
$.ajax({
url: '/SimpleAjaxShit/UserController/' + euserId,
type: 'PUT',
data: user,
success: function(data) {
console.log(data);
},
error: function(data, response) {
console.log(data);
console.log(response);
}
});
$( "#dialog-modal" ).dialog( "close" );
});
和 servlet 中的 doPut 方法,它服务于 ajax 请求
protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String name = request.getParameter("name"); //Null
String surname = request.getParameter("surname"); //Null
String login = request.getParameter("login"); //Null
String password = request.getParameter("password"); //Null
String email = request.getParameter("email"); //Null
}
我可以在标题中看到我的参数,但 request.getParameter("name") 和其他人返回 Null