From 01da3b84d64f138ef7e2c0cc3b87338a34a265a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=AA=E6=83=B3=E5=B9=B2=E9=A5=AD?= <2923443262@qq.com> Date: Sun, 16 Jun 2024 22:58:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../man.jsp" | 124 ++++++++++++++++++ .../man1.jsp" | 12 ++ .../Student.jsp" | 56 ++++++++ .../Student1.jsp" | 66 ++++++++++ .../lj.jsp" | 107 +++++++++++++++ .../lj1.jsp" | 63 +++++++++ 6 files changed, 428 insertions(+) create mode 100644 "work/com/java/minxi/java_20240604/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/man.jsp" create mode 100644 "work/com/java/minxi/java_20240604/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/man1.jsp" create mode 100644 "work/com/java/minxi/java_20240606/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/Student.jsp" create mode 100644 "work/com/java/minxi/java_20240606/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/Student1.jsp" create mode 100644 "work/com/java/minxi/java_20240613/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/lj.jsp" create mode 100644 "work/com/java/minxi/java_20240613/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/lj1.jsp" diff --git "a/work/com/java/minxi/java_20240604/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/man.jsp" "b/work/com/java/minxi/java_20240604/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/man.jsp" new file mode 100644 index 00000000..b61bdf39 --- /dev/null +++ "b/work/com/java/minxi/java_20240604/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/man.jsp" @@ -0,0 +1,124 @@ +<%@ page import="java.sql.DriverManager" %> +<%@ page import="java.sql.Connection" %> +<%@ page import="java.sql.Statement" %> +<%@ page import="java.sql.ResultSet" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="java.util.List" %> + + + Information + + +<%! + public class UserInfo { + private String id; + private String userName; + private String userPhone; + + public UserInfo() { + } + + public UserInfo(String id, String userName, String userPhone) { + this.id = id; + this.userName = userName; + this.userPhone = userPhone; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getUserPhone() { + return userPhone; + } + + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; + } + + @Override + public String toString() { + return "UserInfo{" + + "id='" + id + '\'' + + ", userName='" + userName + '\'' + + ", userPhone='" + userPhone + '\'' + + '}'; + } + } + + public List getUserinfo() { + Connection con = null; + Statement st = null; + ResultSet rs = null; + ArrayList list = new ArrayList<>(); + try { + Class.forName("com.mysql.cj.jdbc.Driver"); + String url = "jdbc:mysql://localhost:3306/student_info?serverTimezone=Asia/Shanghai"; + String username = "root"; + String password = "gcx20050530"; + con = DriverManager.getConnection(url, username, password); + String sql = "select id,user_name,user_phone from user_info;"; + st = con.createStatement(); + rs = st.executeQuery(sql); + + while (rs.next()) { + int id = rs.getInt("id"); + String userName = rs.getString("user_name"); + String userPhone = rs.getString("user_phone"); + UserInfo ui = new UserInfo(); + ui.setId(String.valueOf(Long.parseLong(String.valueOf(id)))); + ui.setUserName(userName); + ui.setUserPhone(userPhone); + list.add(ui); + } + + + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (null != con) { + con.close(); + } + if (rs == null) { + rs.close(); + } + if (st == null) { + st.close(); + } + } catch (Exception e) { + e.printStackTrace(); + } + + } + return list; + + } + +%> +<% + List userinfo = getUserinfo(); + request.getSession().setAttribute("user", userinfo); +%> +try{ + + + +}catch(Exception e){ + +} + + + \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240604/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/man1.jsp" "b/work/com/java/minxi/java_20240604/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/man1.jsp" new file mode 100644 index 00000000..e125d0e5 --- /dev/null +++ "b/work/com/java/minxi/java_20240604/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/man1.jsp" @@ -0,0 +1,12 @@ +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + index1 + + +<% + Object user = session.getAttribute("user"); + out.print(user); +%> + + \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240606/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/Student.jsp" "b/work/com/java/minxi/java_20240606/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/Student.jsp" new file mode 100644 index 00000000..3555d197 --- /dev/null +++ "b/work/com/java/minxi/java_20240606/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/Student.jsp" @@ -0,0 +1,56 @@ +<%@ page import="java.sql.DriverManager" %> +<%@ page import="java.sql.Connection" %> +<%@ page import="java.sql.PreparedStatement" %> +<%@ page import="java.sql.ResultSet" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + 验证 + +<% + request.setCharacterEncoding("utf-8"); + Connection connection = null; + PreparedStatement preparedStatement = null; + ResultSet rs = null; + String userName1 = request.getParameter("userName"); + String password1 = request.getParameter("password"); + try { + Class.forName("com.mysql.cj.jdbc.Driver"); + String url = "jdbc:mysql://localhost:3306/student_info?serverTimezone=Asia/Shanghai"; + String userName = "root"; + String password = "gcx20050530"; + connection = DriverManager.getConnection(url, userName, password); + String sql = "select * from admin where name=? and password=?;"; + preparedStatement = connection.prepareStatement(sql); + preparedStatement.setString(1, userName1); + preparedStatement.setString(2, password1); + rs = preparedStatement.executeQuery(); + if (rs.next()) { +%> + +<% + } else { + response.sendRedirect("index.jsp"); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (null != preparedStatement) { + preparedStatement.close(); + } + if (null != connection) { + connection.close(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } +%> + + + + \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240606/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/Student1.jsp" "b/work/com/java/minxi/java_20240606/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/Student1.jsp" new file mode 100644 index 00000000..b3d7d65d --- /dev/null +++ "b/work/com/java/minxi/java_20240606/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/Student1.jsp" @@ -0,0 +1,66 @@ +<%-- + Created by IntelliJ IDEA. + User: 只想干饭 + Date: 2024/6/16 + Time: 下午10:53 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + 登录 + + + +
+
+ + + + + + + + + + + + + + +
学生系统登录
+ 用户名: + + +
+ 密   码: + + +
+ + + +
+
+
+ + \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240613/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/lj.jsp" "b/work/com/java/minxi/java_20240613/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/lj.jsp" new file mode 100644 index 00000000..10c9e336 --- /dev/null +++ "b/work/com/java/minxi/java_20240613/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/lj.jsp" @@ -0,0 +1,107 @@ +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + 新增 + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
添加学生信息
+ 编号: + + +
+ 姓名: + + +
+ 年龄: + + +
+ 性别: + + 男 + 女 +
+ 电话号码: + + +
+ 住址: + + +
+ 出生日期: + + +
+ 类型: + + 1 + 2 +
+ + + +
+
+
+ + diff --git "a/work/com/java/minxi/java_20240613/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/lj1.jsp" "b/work/com/java/minxi/java_20240613/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/lj1.jsp" new file mode 100644 index 00000000..1a77ce40 --- /dev/null +++ "b/work/com/java/minxi/java_20240613/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/lj1.jsp" @@ -0,0 +1,63 @@ + +<%@ page import="java.sql.DriverManager" %> +<%@ page import="java.sql.Connection" %> +<%@ page import="java.sql.PreparedStatement" %> +<%@ page import="com.sun.corba.se.impl.resolver.SplitLocalResolverImpl" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + + + +<% + request.setCharacterEncoding("utf-8"); + String id = request.getParameter("id"); + String userName1 = request.getParameter("userName"); + String userAge = request.getParameter("userAge"); + String userSex = request.getParameter("userSex"); + String userPhone = request.getParameter("userPhone"); + String userAddress = request.getParameter("userAddress"); + String userTime = request.getParameter("userTime"); + String userType = request.getParameter("userType"); + try { + Class.forName("com.mysql.cj.jdbc.Driver"); + String url="jdbc:mysql://localhost:3306/student_info?serverTimezone=Asia/Shanghai"; + String userName="root"; + String password="gcx20050530"; + Connection connection = DriverManager.getConnection(url, userName, password); + String addSql="insert into user_info values (?,?,?,?,?,?,?,?);"; + PreparedStatement preparedStatement = connection.prepareStatement(addSql); + preparedStatement.setString(1,id); + preparedStatement.setString(2,userName1); + preparedStatement.setString(3,userAge); + preparedStatement.setString(4,userSex); + preparedStatement.setString(5,userPhone); + preparedStatement.setString(6,userAddress); + preparedStatement.setString(7,userTime); + preparedStatement.setString(8,userType); + int i = preparedStatement.executeUpdate(); + if (i>0){ +%> + +<% }else { +%> + +<% + response.sendRedirect("index1.jsp"); + } + }catch (Exception e){ + e.printStackTrace(); + }finally { + try { + + }catch (Exception e){ + e.printStackTrace(); + } + } +%> + + \ No newline at end of file -- Gitee From 8e0be41f53ff745eee0aab477e2faf4a1ee1c768 Mon Sep 17 00:00:00 2001 From: WLL_LL <2923443262@qq.com> Date: Sun, 16 Jun 2024 15:09:27 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20work?= =?UTF-8?q?/com/java/minxi/java=5F20240613/java=5F2301=5F=E9=9F=A6?= =?UTF-8?q?=E5=8A=9B=E8=8E=89=5F2344310139?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lj.jsp" | 107 ------------------ .../lj1.jsp" | 63 ----------- 2 files changed, 170 deletions(-) delete mode 100644 "work/com/java/minxi/java_20240613/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/lj.jsp" delete mode 100644 "work/com/java/minxi/java_20240613/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/lj1.jsp" diff --git "a/work/com/java/minxi/java_20240613/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/lj.jsp" "b/work/com/java/minxi/java_20240613/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/lj.jsp" deleted file mode 100644 index 10c9e336..00000000 --- "a/work/com/java/minxi/java_20240613/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/lj.jsp" +++ /dev/null @@ -1,107 +0,0 @@ -<%@ page contentType="text/html;charset=UTF-8" language="java" %> - - - 新增 - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
添加学生信息
- 编号: - - -
- 姓名: - - -
- 年龄: - - -
- 性别: - - 男 - 女 -
- 电话号码: - - -
- 住址: - - -
- 出生日期: - - -
- 类型: - - 1 - 2 -
- - - -
-
-
- - diff --git "a/work/com/java/minxi/java_20240613/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/lj1.jsp" "b/work/com/java/minxi/java_20240613/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/lj1.jsp" deleted file mode 100644 index 1a77ce40..00000000 --- "a/work/com/java/minxi/java_20240613/java_2301_\351\237\246\345\212\233\350\216\211_2344310139/lj1.jsp" +++ /dev/null @@ -1,63 +0,0 @@ - -<%@ page import="java.sql.DriverManager" %> -<%@ page import="java.sql.Connection" %> -<%@ page import="java.sql.PreparedStatement" %> -<%@ page import="com.sun.corba.se.impl.resolver.SplitLocalResolverImpl" %> -<%@ page contentType="text/html;charset=UTF-8" language="java" %> - - - - - -<% - request.setCharacterEncoding("utf-8"); - String id = request.getParameter("id"); - String userName1 = request.getParameter("userName"); - String userAge = request.getParameter("userAge"); - String userSex = request.getParameter("userSex"); - String userPhone = request.getParameter("userPhone"); - String userAddress = request.getParameter("userAddress"); - String userTime = request.getParameter("userTime"); - String userType = request.getParameter("userType"); - try { - Class.forName("com.mysql.cj.jdbc.Driver"); - String url="jdbc:mysql://localhost:3306/student_info?serverTimezone=Asia/Shanghai"; - String userName="root"; - String password="gcx20050530"; - Connection connection = DriverManager.getConnection(url, userName, password); - String addSql="insert into user_info values (?,?,?,?,?,?,?,?);"; - PreparedStatement preparedStatement = connection.prepareStatement(addSql); - preparedStatement.setString(1,id); - preparedStatement.setString(2,userName1); - preparedStatement.setString(3,userAge); - preparedStatement.setString(4,userSex); - preparedStatement.setString(5,userPhone); - preparedStatement.setString(6,userAddress); - preparedStatement.setString(7,userTime); - preparedStatement.setString(8,userType); - int i = preparedStatement.executeUpdate(); - if (i>0){ -%> - -<% }else { -%> - -<% - response.sendRedirect("index1.jsp"); - } - }catch (Exception e){ - e.printStackTrace(); - }finally { - try { - - }catch (Exception e){ - e.printStackTrace(); - } - } -%> - - \ No newline at end of file -- Gitee