From cd1beb3c424684c3ebe91109127a1109e44b6cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=AA=E4=B8=BA=E7=9C=BC=E4=B8=AD=E7=9A=84=E5=A5=B9?= <3210416196@qq.com> Date: Wed, 5 Jun 2024 10:54:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=96=B0=E5=A2=9E=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/WEB-INF/web.xml" | 6 + .../web/index.jsp" | 116 ++++++++++++++++++ .../web/index1.jsp" | 28 +++++ 3 files changed, 150 insertions(+) create mode 100644 "work/com/java/minxi/java_20240604/java_2301_\345\217\266\345\212\237\347\205\247_2344310115/web/WEB-INF/web.xml" create mode 100644 "work/com/java/minxi/java_20240604/java_2301_\345\217\266\345\212\237\347\205\247_2344310115/web/index.jsp" create mode 100644 "work/com/java/minxi/java_20240604/java_2301_\345\217\266\345\212\237\347\205\247_2344310115/web/index1.jsp" diff --git "a/work/com/java/minxi/java_20240604/java_2301_\345\217\266\345\212\237\347\205\247_2344310115/web/WEB-INF/web.xml" "b/work/com/java/minxi/java_20240604/java_2301_\345\217\266\345\212\237\347\205\247_2344310115/web/WEB-INF/web.xml" new file mode 100644 index 00000000..d80081d1 --- /dev/null +++ "b/work/com/java/minxi/java_20240604/java_2301_\345\217\266\345\212\237\347\205\247_2344310115/web/WEB-INF/web.xml" @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240604/java_2301_\345\217\266\345\212\237\347\205\247_2344310115/web/index.jsp" "b/work/com/java/minxi/java_20240604/java_2301_\345\217\266\345\212\237\347\205\247_2344310115/web/index.jsp" new file mode 100644 index 00000000..a61c24a0 --- /dev/null +++ "b/work/com/java/minxi/java_20240604/java_2301_\345\217\266\345\212\237\347\205\247_2344310115/web/index.jsp" @@ -0,0 +1,116 @@ +<%@ page import="java.sql.*" %> +<%@ page import="java.util.ArrayList" %> +<%@page import="java.lang.*" %> +<%@ page import="java.util.List" %> +<%-- + Created by IntelliJ IDEA. + User: Administrator + Date: 2024-06-04 + Time: 17:53 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + 追究一人 + + +<% + class Userinfo { + private int id; + private String UserName; + private String userPhone; + + public Userinfo() { + this.id = id; + UserName = UserName; + this.userPhone = userPhone; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getUserName() { + return UserName; + } + + public void setUserName(String userName) { + 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 + '\'' + + '}'; + } + } +%> +<% + request.setCharacterEncoding("UTF-8"); + Connection connection = null; + Statement statement = null; + ResultSet resultSet = null; +// try { + Class.forName("com.mysql.cj.jdbc.Driver"); + String url = "jdbc:mysql://localhost:3306/student?serverTimezone=Asia/Shanghai"; + String username = "root"; + String password = "root"; + + connection = DriverManager.getConnection(url, username, password); + statement = connection.createStatement(); + String selectSQL = "select * from user_info;"; + resultSet = statement.executeQuery(selectSQL); + List us = new ArrayList<>(); + while (resultSet.next()) { + Userinfo userinfo = new Userinfo(); + userinfo.setId(resultSet.getInt("id")); + userinfo.setUserName(resultSet.getString("user_name")); + userinfo.setUserPhone(resultSet.getString("user_phone")); + us.add(userinfo); + } + out.print(us); +// for (Userinfo u : us) { +// out.print(u+"
"); +// } +// }catch (Exception e) { +// e.printStackTrace(); +// }finally { +// try{ +// if (null!=resultSet) { + resultSet.close(); +// } +// if (null!=statement){ + statement.close(); +// } +// if (null!=connection){ + connection.close(); +// } +// }catch (Exception e){ +// e.printStackTrace(); +// } +// } +%> +
+ + + + + + + diff --git "a/work/com/java/minxi/java_20240604/java_2301_\345\217\266\345\212\237\347\205\247_2344310115/web/index1.jsp" "b/work/com/java/minxi/java_20240604/java_2301_\345\217\266\345\212\237\347\205\247_2344310115/web/index1.jsp" new file mode 100644 index 00000000..132cdb2e --- /dev/null +++ "b/work/com/java/minxi/java_20240604/java_2301_\345\217\266\345\212\237\347\205\247_2344310115/web/index1.jsp" @@ -0,0 +1,28 @@ +<%@ page import="java.util.List" %> +<%@ page import="java.sql.DriverManager" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="java.sql.ResultSet" %> +<%@ page import="java.sql.Statement" %> +<%@ page import="java.sql.Connection" %><%-- + Created by IntelliJ IDEA. + User: Administrator + Date: 2024-06-04 + Time: 18:20 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Title + + +<% + String us = request.getParameter("id"); + String name = request.getParameter("user_name"); + String userPhone = request.getParameter("user_phone"); + out.println(us+"
"); + out.println(name+"
"); + out.println(userPhone); +%> + + -- Gitee