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 0000000000000000000000000000000000000000..e12ed6bf0029b29d2cc73a26ca4e5164a9512775 --- /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 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 0000000000000000000000000000000000000000..1cccb70ad1bfe46f3809c7922f683e8f68259f94 --- /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,32 @@ +<%@ 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 String getArea(double r){ + if ( r > 0 ){ + double Area = r * r * 3.14; + return " " + Area; + }else { + return "无法计算"; + } + } +%> + +<% +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" new file mode 100644 index 0000000000000000000000000000000000000000..a92b92c0b8a93c8c1dd1bca32aefaa8ac4bb72ca --- /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,36 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> + + + + 06月05日作业 + + + + + + +<%! +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" new file mode 100644 index 0000000000000000000000000000000000000000..2725dbe8ff19b65e36afd54ffc9a09d5ed2ce125 --- /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,22 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> + + + + 06月05日作业 + + +<% +double r = 1,a = 3,b = 6,c = 5; +%> + + + + +

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

+ + + + + + + \ 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/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 0000000000000000000000000000000000000000..34a683cce4f41dfa0485261e09c6fce3e5f89f02 --- /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 0000000000000000000000000000000000000000..6a0ef0eb592e67658d01c0a80c1115c238251013 --- /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 0000000000000000000000000000000000000000..d0406651be0221391000fb5eb439288a124a17b8 --- /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 0000000000000000000000000000000000000000..9442b7feae9e4b83567951dc9f1ba252f98e4b88 --- /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 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 0000000000000000000000000000000000000000..7295108d9b8ded2982f785e5829e8966bda642a9 --- /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