Ajax js 使用Ajax检测用户名是否存在
jsp页面:
web.xml配置文件:public int checkUname(String uname){Connection conn = null;PreparedStatement pstm = null;ResultSet rs = null;int success = 0;String sql = "select u_name from u_info where u_name='"+uname+"' or u_mobtel='"+uname+"' or u_email='"+uname+"'";try {conn = getConnection();pstm = conn.prepareStatement(sql);rs = pstm.executeQuery(sql);if(rs.next()){success = 1;}return success;} catch (Exception e) {e.printStackTrace();} finally {try {conn.close();} catch (Exception e) {e.printStackTrace();}}return success;}
紫色头发:http://zisetoufa.iteye.com