diff --git "a/work/com/java/minxi/java_20240606/java_2301_\351\231\210\346\231\223\344\270\234_2344310111/web3/index1.jsp" "b/work/com/java/minxi/java_20240606/java_2301_\351\231\210\346\231\223\344\270\234_2344310111/web3/index1.jsp" new file mode 100644 index 0000000000000000000000000000000000000000..7fef14b4254d6dadc92c8b7598666415b10295ef --- /dev/null +++ "b/work/com/java/minxi/java_20240606/java_2301_\351\231\210\346\231\223\344\270\234_2344310111/web3/index1.jsp" @@ -0,0 +1,34 @@ +<%-- + Created by IntelliJ IDEA. + User: 陈晓东 + Date: 2024/6/14 + Time: 14:51 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Title + + +
+

登录界面

+ + + + + + + + + + + + + + + +


+
+ + diff --git "a/work/com/java/minxi/java_20240606/java_2301_\351\231\210\346\231\223\344\270\234_2344310111/web3/index2.jsp" "b/work/com/java/minxi/java_20240606/java_2301_\351\231\210\346\231\223\344\270\234_2344310111/web3/index2.jsp" new file mode 100644 index 0000000000000000000000000000000000000000..ed05ad9c61c4a88a889540dace74714953063db9 --- /dev/null +++ "b/work/com/java/minxi/java_20240606/java_2301_\351\231\210\346\231\223\344\270\234_2344310111/web3/index2.jsp" @@ -0,0 +1,59 @@ +<%@ page import="java.sql.PreparedStatement" %> +<%@ page import="java.sql.ResultSet" %> +<%@ page import="java.sql.DriverManager" %> +<%@ page import="com.sun.jdi.connect.spi.Connection" %><%-- + Created by IntelliJ IDEA. + User: 陈晓东 + Date: 2024/6/14 + Time: 14:53 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + 登录成功 + + +<%request.setCharacterEncoding("UTF-8"); + String user_name = request.getParameter("user_name"); + String user_pwd = request.getParameter("user_pwd"); + + 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 JDBCusername = "root"; + String JDBCpassword = "123456"; + conn = (Connection) DriverManager.getConnection(url, JDBCusername, JDBCpassword); + String sql = "select * from user_info where user_name = ? and user_pwd = ?"; + pstmt = ((java.sql.Connection) conn).prepareStatement(sql); + pstmt.setString(1, user_name); + pstmt.setString(2, user_pwd); + rs = pstmt.executeQuery(); + if (rs.next()){ + out.print("欢迎," + user_name + "!"); + }else { + out.print("登录失败,用户名或密码错误!"); + } + } catch (Exception e) { + e.printStackTrace(); + }finally { + try{ + if(rs != null){ + rs.close(); + } + if(pstmt != null){ + pstmt.close(); + } + if(conn != null){ + conn.close(); + } + }catch (Exception e){ + e.printStackTrace(); + } + } +%> +