在Jsp页面上设置method方法为post
1、type:“post”
$("#btn7").click(function(){
$.ajax({
url:"user/doajax7.do",
data:{
username:"张三",
password:"123"
},
// 将type设为post
type:"post",
success:function(data){
var jsonObject =JSON.parse(data);
alert("用户名:"+jsonObject.username+"密码:"+jsonObject.password);
}
});
});
2、表单form里,method=“post”
<form action="dologin.do" method="post">
姓名:<input type="text" name="username"/><br/>
密码:<input type="text" name="password"><br/><br/>
<input type="submit" value="登录">
已经设置了过滤器不知道为什么还有乱码,更改tomcat默认编码格式也试过了,可能和tomcat的版本有问题,有时间试试下载新版本。