请登录后探索更多精彩内容!
上一个操作主要是针对课程,这个主要是针对用户操作。
管理员对用户修改删除模块:管理员可对用户信息进行修改和删除。
管理员对用户修改jsp代码
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ page import="java.sql.*"%> <!DOCTYPE html> <!------------ 管理员-用户修改界面 ---------------> <html> <head> <title>Insert title here</title> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE11" /> </head> <link rel="stylesheet" type="text/css" href="css/style.css"> <body> <% String url = "jdbc:mysql://localhost:3306/user?useUnicode=true&characterEncoding=UTF8"; //数据库名 String username = "root"; //数据库用户名 String password = ""; //数据库用户密码 Connection conn = null; //连接状态 Statement stmt = null; ResultSet rs = null; String stuid=request.getParameter("stuid"); Class.forName("com.mysql.jdbc.Driver"); conn=DriverManager.getConnection(url, username, password); stmt = conn.createStatement(); //查询语句 rs = stmt.executeQuery("SELECT id,stuid,name,class,yx,pwd FROM userxx where stuid='"+stuid+"';"); %> <body bgcolor="#d9e1e8"> <div> <form action="admin_select_process.jsp" method="post"> <table > <caption><h1>修改用户<h1></caption> <%while(rs.next()){ %> <!-- 将查找出来的数据放入到下列输入框中 --> <tr><td><input type="hidden" name="u_id" value="<%=rs.getString("id") %>"></td></tr> <tr><td>学号:<input type="text" name="u_stuid" value="<%=rs.getString("stuid") %>"></td></tr> <tr><td>姓名:<input type="text" name="u_name" value="<%=rs.getString("name") %>"></td></tr> <tr><td>班级:<input type="text" name="u_class" value="<%=rs.getString("class") %>"></td></tr> <tr><td>院系:<input type="text" name="u_yx" value="<%=rs.getString("yx") %>"></td></tr> <tr><td>密码:<input type="text" name="u_pwd" value="<%=rs.getString("pwd") %>"></td></tr> <tr><td><input type="reset" value="清空"/> <input type="submit" value="提交" name="rgsubmit"/></td></tr> <%} rs.close(); conn.close(); %> </table> </form> </div> </body> </html>
管理员对用户删除jsp代码
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ page import="java.sql.*"%> <!DOCTYPE html> <!------------- 管理员删除用户过程 ----------------> <html> <head> <title>Insert title here</title> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE11" /> </head> <body> <% String url = "jdbc:mysql://localhost:3306/user?useUnicode=true&characterEncoding=UTF8"; //数据库名 String username = "root"; //数据库用户名 String password = ""; //数据库用户密码 Connection conn = null; //连接状态 Statement stmt = null; Statement stm = null; ResultSet rs = null; String stuid=request.getParameter("stuid"); Class.forName("com.mysql.jdbc.Driver"); conn=DriverManager.getConnection(url, username, password); stmt = conn.createStatement(); stmt.executeUpdate("delete FROM userxx where stuid='"+stuid+"';"); out.println("<script language='javascript'>alert('删除成功!');window.location.href='userset.jsp';</script>"); %> </body> </body> </html>
管理员添加课程模块:管理员可进行课程添加功能。
管理员添加课程jsp代码
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ page import="java.sql.*"%> <!DOCTYPE html> <!------------- 管理员添加课程界面 -------------------> <html> <head> <title>Insert title here</title> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE11" /> </head> <link rel="stylesheet" type="text/css" href="css/style.css"> <body> <body bgcolor="#d9e1e8"> <div> <form action="admin_ac_process.jsp" method="post"> <table > <caption><h1>添加课程<h1></caption> <tr><td>课程号:<input type="text" name="add_classid" ></td></tr> <tr><td>课程名:<input type="text" name="add_classname" ></td></tr> <tr><td>学分:<input type="text" name="add_point" ></td></tr> <tr><td>老师:<input type="text" name="add_teacher" ></td></tr> <tr><td>地点:<input type="text" name="add_place" ></td></tr> <tr><td>时间:<input type="text" name="add_classtime"></td></tr> <tr><td><input type="reset" value="清空"/> <input type="submit" value="提交" name="rgsubmit"/></td></tr> </table> </form> </div> </body> </html>
添加课程过程处理jsp页面代码
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ page import="java.sql.*"%> <!DOCTYPE html> <!------------- 管理员添加课程过程 ----------------> <html> <head> <title>Insert title here</title> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE11" /> </head> <body> <% String url = "jdbc:mysql://localhost:3306/user?useUnicode=true&characterEncoding=UTF8"; //数据库名 String username = "root"; //数据库用户名 String password = ""; //数据库用户密码 Connection conn = null; //连接状态 Statement stmt = null; ResultSet rs = null; request.setCharacterEncoding("utf-8"); String classid = request.getParameter("add_classid"); String classname = request.getParameter("add_classname"); String point = request.getParameter("add_point"); String teacher = request.getParameter("add_teacher"); String place = request.getParameter("add_place"); String classtime = request.getParameter("add_classtime"); Class.forName("com.mysql.jdbc.Driver"); conn=DriverManager.getConnection(url, username, password); stmt = conn.createStatement(); stmt.executeUpdate("insert into classsql (classid,classname,point,teacher,place,classtime) values('"+classid+"','"+classname+"','"+point+"','"+teacher+"','"+place+"','"+classtime+"');"); out.println("<script language='javascript'>alert('添加成功!');window.location.href='admin_classtable.jsp';</script>"); %> </body> </html>
漏了个添加课程,在这里补上了
每日回帖拿金币 感谢分享
金币好难得
好久没来了,今天看站长分享了jsp相关的技术文档,特意来学习一下,刚好我最近也学到了jsp
请先登录后发表评论!