简体   繁体   English

无法将值ajax传递给servlet

[英]Can't pass a value ajax to servlet

I have a simple code here, 我这里有一个简单的代码,

$.ajax({
        url: "updateAccount",
        type: "POST",
        data:  {username : "username",pasword:"pasw" , Id : "123"},
        success: function(response) {
            if (response === "success") {
                alert("update success");
                location.href = "account.jsp";
                loadData();
            } else {
                alert("update fail");
            }
        },
        error: function() {
            alert("execute fail");
        }
    });

but in my servlet: 但在我的servlet中:

if (userPath.equals("/updateAccount")) {
    String id = request.getParameter("Id");
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    AccountDTO accountDTO = new AccountDTO();
    //accountDTO.setId(id);
    accountDTO.setUsername(username);
    accountDTO.setPassword(password);
    out.print(accountBS.updateAccount(accountDTO));
}

I just only get the value of Id, and username. 我只得到ID和用户名的值。 Value of the parameter password = null .Why and how can i get all of id,username,password values. 参数password = null为什么以及如何获取所有ID,用户名和密码值。

修改代码如下,密钥密码拼写错误

data:  {username : "username",password:"pasw" , Id : "123"}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM