From e889ed5103ce2ef7a5c4042cff93ad509fde0d22 Mon Sep 17 00:00:00 2001 From: ccc <1572227662@qq.com> Date: Mon, 3 Jun 2024 23:48:26 +0800 Subject: [PATCH 1/6] =?UTF-8?q?6.03=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../circle.jsp" | 25 +++++++++++++ .../ladder.jsp" | 37 +++++++++++++++++++ .../main.jsp" | 26 +++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 "work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/circle.jsp" create mode 100644 "work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/ladder.jsp" create mode 100644 "work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/main.jsp" diff --git "a/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/circle.jsp" "b/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/circle.jsp" new file mode 100644 index 00000000..8549da4d --- /dev/null +++ "b/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/circle.jsp" @@ -0,0 +1,25 @@ +<%@ page import="static java.lang.System.out" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + + circle + + +

这里是circle

+ +<%--计算圆的面积--%> +

+<%! + public double getArea(double a,int r){ + double area =a * r * r; + return area; + } +%> +<% + +%> + +

+ + \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/ladder.jsp" "b/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/ladder.jsp" new file mode 100644 index 00000000..dc7836d4 --- /dev/null +++ "b/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/ladder.jsp" @@ -0,0 +1,37 @@ +<%@ page import="static java.lang.System.out" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + + ladder + + +

这里是ladder

+ +<%--计算梯形的面积--%> +

+ <%! + public String getArea(int up, int un, int he){ + if(up != un) { + int area = ((up + un) * he)/2; + return ("梯形的面积是:"+area); + }else { + return("上底"+up+"与下底"+un+"相等所以该图形不是梯形"); + } + } + %> +

+<% + String a = request.getParameter("upper"); + String b = request.getParameter("under"); + String c = request.getParameter("height"); + int upper = Integer.parseInt(a); + int under = Integer.parseInt(b); + int height = Integer.parseInt(c); +%> +

+
给我传递的值是:<%=a%>,<%=b%>,<%=c%> +
梯形的面积是:<%=getArea(upper,under,height)%> +

+ + \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/main.jsp" "b/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/main.jsp" new file mode 100644 index 00000000..996c9b2b --- /dev/null +++ "b/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/main.jsp" @@ -0,0 +1,26 @@ + + + + main + + +

这里是main

+<%double a = 3.14; int r = 3;%> +<%int upper = 5, under = 2, height = 3;%> + + + + + + + + + + + + + + + + + \ No newline at end of file -- Gitee From f339a1ae321642c70f0452e8d682f459a2cb5b71 Mon Sep 17 00:00:00 2001 From: ccc <1572227662@qq.com> Date: Tue, 4 Jun 2024 16:55:19 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feat:6.03=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../circle.jsp" | 9 ++++++--- .../main.jsp" | 9 ++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git "a/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/circle.jsp" "b/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/circle.jsp" index 8549da4d..2f9b1fb8 100644 --- "a/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/circle.jsp" +++ "b/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/circle.jsp" @@ -11,14 +11,17 @@ <%--计算圆的面积--%>

<%! - public double getArea(double a,int r){ - double area =a * r * r; + public double getArea(int r){ + double area =3.14 * r * r; return area; } %> <% - + String a = request.getParameter("r"); + int r = Integer.parseInt(a); %> +

给我传的值:<%=a%>

+

圆的面积是:<%=getArea(r)%>

diff --git "a/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/main.jsp" "b/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/main.jsp" index 996c9b2b..5b3a5213 100644 --- "a/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/main.jsp" +++ "b/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/main.jsp" @@ -5,21 +5,20 @@

这里是main

-<%double a = 3.14; int r = 3;%> +<%int r = 3;%> <%int upper = 5, under = 2, height = 3;%> - - - - + + + -- Gitee From 02ae6d64e631685458cc368ca3b9337f69a415a5 Mon Sep 17 00:00:00 2001 From: ccc <1572227662@qq.com> Date: Tue, 4 Jun 2024 16:57:12 +0800 Subject: [PATCH 3/6] =?UTF-8?q?feat:6.03=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main.jsp" | 2 ++ 1 file changed, 2 insertions(+) diff --git "a/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/main.jsp" "b/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/main.jsp" index 5b3a5213..74bffefe 100644 --- "a/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/main.jsp" +++ "b/work/com/java/minxi/java_20240603/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/main.jsp" @@ -1,3 +1,5 @@ +<%@ page import="static java.lang.System.out" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> -- Gitee From 3a3f25184ef35b098a519fd0fc147d54c1d34296 Mon Sep 17 00:00:00 2001 From: ccc <1572227662@qq.com> Date: Wed, 5 Jun 2024 22:04:14 +0800 Subject: [PATCH 4/6] =?UTF-8?q?6.03=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/WEB-INF/web.xml" | 6 ++ .../web/index.jsp" | 85 +++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 "work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/web/WEB-INF/web.xml" create mode 100644 "work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/web/index.jsp" diff --git "a/work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/web/WEB-INF/web.xml" "b/work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/web/WEB-INF/web.xml" new file mode 100644 index 00000000..d80081d1 --- /dev/null +++ "b/work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/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_\351\231\210\344\277\212\346\235\260_2315340142/web/index.jsp" "b/work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/web/index.jsp" new file mode 100644 index 00000000..79accfd3 --- /dev/null +++ "b/work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/web/index.jsp" @@ -0,0 +1,85 @@ +<%@ page import="static java.lang.System.out" %> +<%@ page import="java.sql.DriverManager" %> +<%@ page import="java.sql.Connection" %> +<%@ page import="java.sql.Statement" %> +<%@ page import="java.sql.ResultSet" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + + index.jsp + + +<%! + + public static List list = new ArrayList<>(); + public class UserInfo{ + private int id; + private String userName; + private String userPhone; + + public UserInfo() { + } + + public UserInfo(int id, String userName, String userPhone) { + this.id = id; + this.userName = userName; + this.userPhone = userPhone; + } + + @Override + public String toString() { + return "UserInfo{" + + "id=" + id + + ", userName='" + userName + '\'' + + ", userPhone='" + userPhone + '\'' + + '}'; + } + } +%> +

+<% + + Connection connection = null; + Statement statement = null; + ResultSet resultSet = null; + try { + Class.forName("com.java.cj.jdbc.Driver"); + String url = "mysql:jdbc://localhost:3306/student?serverTimezone=Asia/Shanghai"; + String username = "root"; + String password = "123456"; + connection = DriverManager.getConnection(url, username, password); + String sql = ("select id, user_name, user_phone from user_info;"); + statement = connection.createStatement(); + resultSet = statement.executeQuery(sql); + while(resultSet.next()){ + UserInfo userInfo = new UserInfo(resultSet.getInt("id"),resultSet.getNString("user_name"),resultSet.getNString("user_phone")); + list.add(userInfo); + } + for (UserInfo userInfo : list) { + out.print(userInfo); + } + } 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(); + } + } +%> +

+ + \ No newline at end of file -- Gitee From 15052042500022ae145fb2447f9cebfcce6301b7 Mon Sep 17 00:00:00 2001 From: ccc <1572227662@qq.com> Date: Wed, 5 Jun 2024 23:48:17 +0800 Subject: [PATCH 5/6] =?UTF-8?q?6.04=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/index.jsp" | 45 ++++++++++++++----- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git "a/work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/web/index.jsp" "b/work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/web/index.jsp" index 79accfd3..9a781fee 100644 --- "a/work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/web/index.jsp" +++ "b/work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/web/index.jsp" @@ -1,4 +1,3 @@ -<%@ page import="static java.lang.System.out" %> <%@ page import="java.sql.DriverManager" %> <%@ page import="java.sql.Connection" %> <%@ page import="java.sql.Statement" %> @@ -12,10 +11,9 @@ index.jsp +

作业

<%! - - public static List list = new ArrayList<>(); - public class UserInfo{ + public static class UserInfo{ private int id; private String userName; private String userPhone; @@ -29,6 +27,30 @@ 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) { + this.userName = userName; + } + + public String getUserPhone() { + return userPhone; + } + + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; + } + @Override public String toString() { return "UserInfo{" + @@ -39,23 +61,24 @@ } } %> -

+

作业

+

<% - + List list = new ArrayList<>(); Connection connection = null; Statement statement = null; ResultSet resultSet = null; try { - Class.forName("com.java.cj.jdbc.Driver"); - String url = "mysql:jdbc://localhost:3306/student?serverTimezone=Asia/Shanghai"; + Class.forName("com.mysql.cj.jdbc.Driver"); + String url = "jdbc:mysql://localhost:3306/student?serverTimezone=Asia/Shanghai"; String username = "root"; String password = "123456"; connection = DriverManager.getConnection(url, username, password); - String sql = ("select id, user_name, user_phone from user_info;"); + String sql="select id,user_name,user_phone from user_info;"; statement = connection.createStatement(); resultSet = statement.executeQuery(sql); while(resultSet.next()){ - UserInfo userInfo = new UserInfo(resultSet.getInt("id"),resultSet.getNString("user_name"),resultSet.getNString("user_phone")); + UserInfo userInfo = new UserInfo(resultSet.getInt("id"),resultSet.getString("user_phone"),resultSet.getString("user_name")); list.add(userInfo); } for (UserInfo userInfo : list) { @@ -80,6 +103,6 @@ } } %> -

+

\ No newline at end of file -- Gitee From d7090e73578fd6b9a5f15e66f29a4a01aee170de Mon Sep 17 00:00:00 2001 From: ccc <1572227662@qq.com> Date: Thu, 6 Jun 2024 11:34:42 +0800 Subject: [PATCH 6/6] =?UTF-8?q?6.04=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/index.jsp" | 26 ++++++++++--------- .../web/index1.jsp" | 21 +++++++++++++++ 2 files changed, 35 insertions(+), 12 deletions(-) create mode 100644 "work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/web/index1.jsp" diff --git "a/work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/web/index.jsp" "b/work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/web/index.jsp" index 9a781fee..428dbe42 100644 --- "a/work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/web/index.jsp" +++ "b/work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/web/index.jsp" @@ -8,12 +8,11 @@ - index.jsp + 作业 -

作业

<%! - public static class UserInfo{ + public static class UserInfo { private int id; private String userName; private String userPhone; @@ -61,8 +60,7 @@ } } %> -

作业

-

+ <% List list = new ArrayList<>(); Connection connection = null; @@ -74,19 +72,20 @@ String username = "root"; String password = "123456"; connection = DriverManager.getConnection(url, username, password); - String sql="select id,user_name,user_phone from user_info;"; + String sql = "select id,user_name,user_phone from user_info;"; statement = connection.createStatement(); resultSet = statement.executeQuery(sql); - while(resultSet.next()){ - UserInfo userInfo = new UserInfo(resultSet.getInt("id"),resultSet.getString("user_phone"),resultSet.getString("user_name")); + while (resultSet.next()) { + UserInfo userInfo = new UserInfo(resultSet.getInt("id"), resultSet.getString("user_phone"), resultSet.getString("user_name")); list.add(userInfo); } for (UserInfo userInfo : list) { out.print(userInfo); } + } catch (Exception e) { e.printStackTrace(); - }finally { + } finally { //释放资源 try { if (null != resultSet) { @@ -96,13 +95,16 @@ statement.close(); } if (null != connection) { - connection.close(); - } + connection.close(); } } catch (Exception e) { e.printStackTrace(); } } %> -

+ + + + + \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/web/index1.jsp" "b/work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/web/index1.jsp" new file mode 100644 index 00000000..905309b2 --- /dev/null +++ "b/work/com/java/minxi/java_20240604/java_2301_\351\231\210\344\277\212\346\235\260_2315340142/web/index1.jsp" @@ -0,0 +1,21 @@ +<%-- + Created by IntelliJ IDEA. + User: Administrator + Date: 2024/6/6 + Time: 11:27 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + 作业 + + +<% + String list = request.getParameter("list"); +%> +

<% + out.print(list); +%>

+ + -- Gitee