From e02a64f428ef8f523deb6c6344d219098b2496c1 Mon Sep 17 00:00:00 2001 From: Chenyabin <3497422417@qq.com> Date: Mon, 3 Jun 2024 19:18:57 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat=EF=BC=9A=E6=8F=90=E4=BA=A4=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../text.jsp" | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 "work/com/java/minxi/java_20240531/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/text.jsp" diff --git "a/work/com/java/minxi/java_20240531/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/text.jsp" "b/work/com/java/minxi/java_20240531/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/text.jsp" new file mode 100644 index 0000000..e12ed6b --- /dev/null +++ "b/work/com/java/minxi/java_20240531/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/text.jsp" @@ -0,0 +1,71 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> + + + + 5月31日作业 + + + +

+ + +<%! + //定义一个Animal类,并在类中定义一个String sleep(int time)的成员方法 + class Animal{ + String sleep(int time){ + return "一只动物在睡觉"; + } + } + + + //定义一个Cat类,包含name及time的属性,并定义String sleep(int time)的方法; + class Cat{ + private String name; + private int time; + + public Cat() { + } + public Cat(String name, int time) { + this.name = name; + this.time = time; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public int getTime() { + return time; + } + public void setTime(int time) { + this.time = time; + } + String sleep(){ + String aa = "一只"+this.getName()+"睡觉睡了"+this.getTime()+"小时"; + return aa; + } + } +%> +<% + Animal animal = new Animal(); + out.println(animal.sleep(1)); +%> +
+<% + Cat cat = new Cat("汤姆猫",8); + out.println(cat.sleep()); +%> + +
+<% + for (int i = 1; i <= 9 ; i++) { + for (int j = 1; j <= i; j++) { + out.println(i + "*" + j +"=" +i * j + "\t"); + } + out.println("
"); + } +%> +

+ + \ No newline at end of file -- Gitee From 079f40dad96c82f63fcf149a1e1bad49ec9db6d0 Mon Sep 17 00:00:00 2001 From: chenyabin <2397422417@qq.com> Date: Wed, 5 Jun 2024 17:34:28 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat:=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 --- .../circle.jsp" | 36 +++++++++++++++++++ .../ladder.jsp" | 23 ++++++++++++ .../mian.jsp" | 17 +++++++++ 3 files changed, 76 insertions(+) create mode 100644 "work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/circle.jsp" create mode 100644 "work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/ladder.jsp" create mode 100644 "work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/mian.jsp" diff --git "a/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/circle.jsp" "b/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/circle.jsp" new file mode 100644 index 0000000..e394bad --- /dev/null +++ "b/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/circle.jsp" @@ -0,0 +1,36 @@ +<%@ page import="java.util.Scanner" %> +<%@ page import="java.util.Arrays" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> + + + + 06月05日作业 + + + + + + +<%! + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + System.out.println("请输入所求圆形的半径:"); + int r = scanner.nextInt(); + System.out.println("所求圆形的半径为:"+r); + float a = 3.14f; + System.out.println("圆形的面积为:"+r*r*a); + } + public int getArea(int r){ + return r; + } + +%> + +<% + String r = request.getParameter("r"); + out.println(r); +%> + + + \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/ladder.jsp" "b/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/ladder.jsp" new file mode 100644 index 0000000..3c12196 --- /dev/null +++ "b/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/ladder.jsp" @@ -0,0 +1,23 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> + + + + 06月05日作业 + + + + + + +<%! + + +%> + +<% + + +%> + + + \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/mian.jsp" "b/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/mian.jsp" new file mode 100644 index 0000000..a53e29f --- /dev/null +++ "b/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/mian.jsp" @@ -0,0 +1,17 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> + + + + 06月05日作业 + + + + + + + + + + + + \ No newline at end of file -- Gitee From c60bda449584b13c9c609a71fad52020ba1665ce Mon Sep 17 00:00:00 2001 From: chenyabin <3497422417@qq.com> Date: Wed, 5 Jun 2024 19:10:34 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feat:=E4=BF=AE=E6=94=B9=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../circle.jsp" | 28 ++++++++----------- .../ladder.jsp" | 19 +++++++++++-- .../mian.jsp" | 11 ++++++-- 3 files changed, 36 insertions(+), 22 deletions(-) diff --git "a/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/circle.jsp" "b/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/circle.jsp" index e394bad..1cccb70 100644 --- "a/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/circle.jsp" +++ "b/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/circle.jsp" @@ -12,25 +12,21 @@ <%! - - public static void main(String[] args) { - Scanner scanner = new Scanner(System.in); - System.out.println("请输入所求圆形的半径:"); - int r = scanner.nextInt(); - System.out.println("所求圆形的半径为:"+r); - float a = 3.14f; - System.out.println("圆形的面积为:"+r*r*a); - } - public int getArea(int r){ - return r; - } - + public String getArea(double r){ + if ( r > 0 ){ + double Area = r * r * 3.14; + return " " + Area; + }else { + return "无法计算"; + } + } %> <% - String r = request.getParameter("r"); - out.println(r); +String sideR = request.getParameter("sideR"); +double r = Double.parseDouble(sideR); %> - +
圆的半径为:<%= r %> +
圆的面积为:<%= getArea(r) %> \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/ladder.jsp" "b/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/ladder.jsp" index 3c12196..a92b92c 100644 --- "a/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/ladder.jsp" +++ "b/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/ladder.jsp" @@ -10,14 +10,27 @@ <%! - +public String getArea(double a,double b,double c){ + if (a > 0 && b > 0 && c > 0){ + double area = (a + b) * c / 2; + return " " + area; + }else { + return "无法计算"; + } +} %> <% - - +String sideA = request.getParameter("sideA"); +String sideB = request.getParameter("sideB"); +String sideC = request.getParameter("sideC"); +double a = Double.parseDouble(sideA); +double b = Double.parseDouble(sideB); +double c = Double.parseDouble(sideC); %> +
梯形的上底、下底、高分别是:<%= sideA%> <%= sideB%> <%= sideC%> +
梯形的面积是:<%= getArea(a,b,c)%> \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/mian.jsp" "b/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/mian.jsp" index a53e29f..2725dbe 100644 --- "a/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/mian.jsp" +++ "b/work/com/java/minxi/java_20240605/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/mian.jsp" @@ -5,13 +5,18 @@ 06月05日作业 +<% +double r = 1,a = 3,b = 6,c = 5; +%> - + - +

=================================================

- + + + \ No newline at end of file -- Gitee From 9c93fdfa339554a9f6291c6996679fbb0e7de74a Mon Sep 17 00:00:00 2001 From: chenyabin <3497422417@qq> Date: Thu, 6 Jun 2024 11:39:18 +0800 Subject: [PATCH 4/5] =?UTF-8?q?feat:=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 --- .../index1.jsp" | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 "work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/index1.jsp" diff --git "a/work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/index1.jsp" "b/work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/index1.jsp" new file mode 100644 index 0000000..7295108 --- /dev/null +++ "b/work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/index1.jsp" @@ -0,0 +1,41 @@ +<%@ page import="java.sql.*" %> +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="UTF-8" %> + + + + 这是一个JavaWeb页面 + + + + + +<%! + public static void Class() throws Exception{ + Class.forName("com.mysql.cj.jdbc.Driver"); + String URL = "jdbc:mysql://localhost:3306/student?severTimezone/Asia/Shanghai"; + String username = "root"; + String password = "123456"; + Connection connection = DriverManager.getConnection(URL,username,password); + String sql = "select * form user_info"; + PreparedStatement preparedStatement = connection.prepareStatement(sql); + ResultSet resultSet = preparedStatement.executeQuery(); + while (resultSet.next()){ + int id = resultSet.getInt("id"); + String name = resultSet.getString("name"); + String phone = resultSet.getString("phone"); + System.out.println(id + "&&" + name + "&&" + phone); + } + resultSet.close(); + preparedStatement.close(); + connection.close(); + } +%> + + +<% + +%> + + + + \ No newline at end of file -- Gitee From 417b16b48eaeb9c34dc6f86f35ade92e72a58ed2 Mon Sep 17 00:00:00 2001 From: chenyabin <3497422417@qq.com> Date: Tue, 18 Jun 2024 20:35:55 +0800 Subject: [PATCH 5/5] =?UTF-8?q?feat:=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 --- .../Text1/index1.jsp" | 106 ++++++++++++++++++ .../Text1/index2.jsp" | 65 +++++++++++ .../Text2/index1.jsp" | 13 +++ .../Text2/index2.jsp" | 34 ++++++ 4 files changed, 218 insertions(+) create mode 100644 "work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/Text1/index1.jsp" create mode 100644 "work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/Text1/index2.jsp" create mode 100644 "work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/Text2/index1.jsp" create mode 100644 "work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/Text2/index2.jsp" diff --git "a/work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/Text1/index1.jsp" "b/work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/Text1/index1.jsp" new file mode 100644 index 0000000..34a683c --- /dev/null +++ "b/work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/Text1/index1.jsp" @@ -0,0 +1,106 @@ +0<%@ page import="java.sql.*" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="UTF-8" %> + + + + 这是一个JavaWeb页面 + + + + + +<%! + 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; + } + + 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{" + + "id=" + id + + ", userName='" + userName + '\'' + + ", userPhone='" + userPhone + '\'' + + '}'; + } + } + public List Class() throws Exception{ + List userinfo = new ArrayList<>(); + Class.forName("com.mysql.cj.jdbc.Driver"); + String URL = "jdbc:mysql://localhost:3306/student?severTimezone/Asia/Shanghai"; + String username = "root"; + String password = "123456"; + Connection connection = DriverManager.getConnection(URL,username,password); + String sql = "select * form user_info"; + PreparedStatement preparedStatement = connection.prepareStatement(sql); + ResultSet resultSet = preparedStatement.executeQuery(); + while (resultSet.next()){ + int id = resultSet.getInt("id"); + String name = resultSet.getString("name"); + String phone = resultSet.getString("phone"); + System.out.println(id + "&&" + name + "&&" + phone); + Userinfo userinfo1 = new Userinfo(); + userinfo1.setId(id); + userinfo1.setUserName(name); + userinfo1.setUserPhone(phone); + userinfo.add(userinfo1); + } + resultSet.close(); + preparedStatement.close(); + connection.close(); + return userinfo; + } +%> +[ + +<% +List userinfo = Class(); + for (int i = 0; i < userinfo.size(); i++) { + if (i == userinfo.size()-1){ + System.out.println(userinfo.get(i).toString()); + }else { + System.out.println(userinfo.get(i).toString() + ",
"); + } + } +%> +] + + + + + \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/Text1/index2.jsp" "b/work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/Text1/index2.jsp" new file mode 100644 index 0000000..6a0ef0e --- /dev/null +++ "b/work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/Text1/index2.jsp" @@ -0,0 +1,65 @@ +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="UTF-8" %> + + + + 这是一个JavaWeb页面 + + + + + +<%! + 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; + } + + 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{" + + "id=" + id + + ", userName='" + userName + '\'' + + ", userPhone='" + userPhone + '\'' + + '}'; + } + } + +%> + + + + + \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/Text2/index1.jsp" "b/work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/Text2/index1.jsp" new file mode 100644 index 0000000..d040665 --- /dev/null +++ "b/work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/Text2/index1.jsp" @@ -0,0 +1,13 @@ +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + 这是一个JavaWeb页面 + + +
+
+
+ +
+ + \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/Text2/index2.jsp" "b/work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/Text2/index2.jsp" new file mode 100644 index 0000000..9442b7f --- /dev/null +++ "b/work/com/java/minxi/java_20240606/java_2302_\351\231\210\351\233\205\345\256\276_2344310213/Text2/index2.jsp" @@ -0,0 +1,34 @@ +<%@ page import="java.sql.*" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + 这是一个JavaWeb页面 + + +<%! + public static int login(String userName,String passWord) throws Exception{ + Class.forName("com.mysql.cj.jdbc.Driver"); + String url = "jdbc:mysql://localhost:3306/student?serverTimezone=Asia/Shanghai"; + String username = "root"; + String password = "123456"; + Connection conn = DriverManager.getConnection(url, username, password); + String sql = "select id from user_info where user_name = ? and user_pwd = ?"; + PreparedStatement preparedStatement = conn.prepareStatement(sql); + preparedStatement.setString(1,userName); + preparedStatement.setString(2,passWord); + ResultSet resultSet = preparedStatement.executeQuery(); + int result = 0; + while (resultSet.next()){ + result = resultSet.getInt(1); + } + resultSet.close(); + preparedStatement.close(); + conn.close(); + return result; + } +%> + +<% +%> + + \ No newline at end of file -- Gitee