1 回答
TA贡献1788条经验 获得超4个赞
ajax数据传到后台
1 2 3 4 5 6 7 8 9 | $.ajax({ type: "GET", //POST url: "***.action", data: {username:$("#username").val(), content:$("#content").val()}, //组装参数 dataType: "json", success: function(data){ alert('成功'); } }); |
后台java;
String username = request.getParameter("username");
String content = request.getParameter("content");
忘记了,你说request不能用,那就定义两个变量
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | private String username; private String content;
public String getUsername() { return username; }
public void setUsername(String username) { this.username = username; }
public String getContent() { return content; }
public void setContent(String content) { this.content = content; } |
- 1 回答
- 0 关注
- 418 浏览
添加回答
举报