From 09c4a870015440228bda7ab6b59acf1587e8bac3 Mon Sep 17 00:00:00 2001 From: "1967671450@qq.com" <1967671450@qq.com> Date: Fri, 14 Jun 2024 08:51:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:6.06=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../index1.jsp" | 23 +++++++ .../index2.jsp" | 63 +++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 "work/com/java/minxi/java_20240606/java_2301_\345\255\231\345\205\210\344\274\230_2344310146/index1.jsp" create mode 100644 "work/com/java/minxi/java_20240606/java_2301_\345\255\231\345\205\210\344\274\230_2344310146/index2.jsp" diff --git "a/work/com/java/minxi/java_20240606/java_2301_\345\255\231\345\205\210\344\274\230_2344310146/index1.jsp" "b/work/com/java/minxi/java_20240606/java_2301_\345\255\231\345\205\210\344\274\230_2344310146/index1.jsp" new file mode 100644 index 00000000..a5b0a7b9 --- /dev/null +++ "b/work/com/java/minxi/java_20240606/java_2301_\345\255\231\345\205\210\344\274\230_2344310146/index1.jsp" @@ -0,0 +1,23 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> + + + + 登录 + + +

用户登录

+
+
+ + 用户名: +
+
+ 密码: + 用户名: +
+
+ +
+
+ + \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240606/java_2301_\345\255\231\345\205\210\344\274\230_2344310146/index2.jsp" "b/work/com/java/minxi/java_20240606/java_2301_\345\255\231\345\205\210\344\274\230_2344310146/index2.jsp" new file mode 100644 index 00000000..3705d588 --- /dev/null +++ "b/work/com/java/minxi/java_20240606/java_2301_\345\255\231\345\205\210\344\274\230_2344310146/index2.jsp" @@ -0,0 +1,63 @@ +<%@ page import="java.sql.DriverManager" %> +<%@ page import="java.sql.Connection" %> +<%@ page import="java.sql.PreparedStatement" %> +<%@ page import="java.sql.ResultSet" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> + + + + + + +<% + String user_name = request.getParameter("username"); + String user_pwd = request.getParameter("password"); + + + Connection conn = null; + PreparedStatement pstmt = null; + ResultSet rs = null; + try { +// 注册驱动 + Class.forName("com.mysql.cj.jdbc.Driver"); +// 获取链接 + String url = "jdbc:mysql://localhost:3306/student?serverTimezone=Asia/Shanghai"; + String username = "root"; + String password = "031002"; + conn = DriverManager.getConnection(url, username,password); +// 定义sql + String sql = "select * from user_info where user_name=? and user_pwd=?;"; +// 获取对象 + pstmt = conn.prepareStatement(sql); +// 输入?的值 + pstmt.setString(1,user_name); + pstmt.setString(2,user_pwd); +// 执行sql + rs = pstmt.executeQuery(); +if (rs.next()){ + out.print("欢迎"+username+",登录成功"); +}else { + out.print("登录失败"); +} + + } catch (Exception e) { + e.printStackTrace(); + }finally { + try{ + if (null!=conn){ + conn.close(); + } + if (null!=pstmt){ + pstmt.close(); + } + if (null!=rs){ + rs.close(); + } + + }catch (Exception e){ + e.printStackTrace(); + } + } +%> + + \ No newline at end of file -- Gitee