后台返回到前台
boolean a = updateService.updateName(username); if(a == true){ System.out.println(a); response.getWriter().write("1"); }else { System.out.println("not find"); response.getWriter().write("-1"); }
boolean a = updateService.userpass(password,username); if(a == true){ System.out.println("a="+a); response.getWriter().write("2"); }else { System.out.println("sorry not find"); response.getWriter().write("-2"); }
前台获取
success : function(resp,opt){ temp = resp.responseText; if(temp == ‘1‘){ Ext.MessageBox.alert(‘提示‘, ‘能查到该用户‘); Ext.Ajax.request({ url : ‘update.do?method=pass‘, method : ‘post‘, params : {username: username,password: newId1}, success : function(resp,opt){ demp = resp.responseText; if(demp == ‘2‘){ Ext.MessageBox.alert(‘提示‘, ‘修改成功‘); }else{ Ext.MessageBox.alert(‘提示‘, ‘修改失败‘); } } }) }else{Ext.MessageBox.alert(‘提示‘, ‘用户名不存在‘);} }
后台
response.getWriter().write("1");数字要加引号,否则前台都是false
时间: 2024-10-05 06:13:00