这是前端用ajax向后台传值的部分代码
<script type="text/javascript">
function checkselect(){
$.ajax({
async:false,
cache:false,
type:'post',
url:'ChangeServlet',
data:{username:Username,password:Password,changepass:ChangePass},
success:function(data){
if(data == 1){
alert("密码修改成功!");
}else if(data == 0){
alert("账号与原密码不匹配,请重新输入!");
}
},
error : function() {
alert("网络故障!");
}
});
}
</script>
后台实现功能代码如下
String sql = "select * from LoginUser where UserName = '"+username+"' and LoginPwd = '"+pasword+"'";
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
if(rs.next()){
String isExit = "update LoginUser set LoginPwd = ? where UserName = '"+username+"'";
PreparedStatement ps2 = conn.prepareStatement(isExit);
ps2.setString(1,changepass);
ps2.executeUpdate();
ps2.close();
conn.close();
}else{
}
rs.close();
ps.close();
conn.close();
后台是servlet,在“conn.close()”之后判定data=1,在else里面判定data=0,并将它们的值传回前台应该怎么写?