diff --git "a/work/com/java/minxi/java_20240603/java_2301_\345\256\213\345\207\257_2344310137/Main0603.jsp" "b/work/com/java/minxi/java_20240603/java_2301_\345\256\213\345\207\257_2344310137/Main0603.jsp" deleted file mode 100644 index 9830e92d4f40fd7b43c69c0e011b76d46d31c107..0000000000000000000000000000000000000000 --- "a/work/com/java/minxi/java_20240603/java_2301_\345\256\213\345\207\257_2344310137/Main0603.jsp" +++ /dev/null @@ -1,20 +0,0 @@ -<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> - - - 计算图形面积 - - -

计算图形面积

- - - - - - - - - - - - - \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240603/java_2301_\345\256\213\345\207\257_2344310137/circle.jsp" "b/work/com/java/minxi/java_20240603/java_2301_\345\256\213\345\207\257_2344310137/circle.jsp" deleted file mode 100644 index ca8d3434bdf7f85b2fd0d7a4143a44ed0592992f..0000000000000000000000000000000000000000 --- "a/work/com/java/minxi/java_20240603/java_2301_\345\256\213\345\207\257_2344310137/circle.jsp" +++ /dev/null @@ -1,25 +0,0 @@ -<%@ page import="java.text.DecimalFormat" %> -<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> - - - 圆形 - - -<% - //获取圆的半径 - String radiusStr = request.getParameter("radius"); - double radius = Double.parseDouble(radiusStr); - - //计算圆的面积 - double area = Math.PI * Math.pow(radius,2); - - //格式化输出 - DecimalFormat df = new DecimalFormat("#.00"); -%> -
-

圆的面积

- 半径:<%= radius %>
- 面积:<%= df.format(area) %>
-
- - diff --git "a/work/com/java/minxi/java_20240603/java_2301_\345\256\213\345\207\257_2344310137/ladder.jsp" "b/work/com/java/minxi/java_20240603/java_2301_\345\256\213\345\207\257_2344310137/ladder.jsp" deleted file mode 100644 index 89f8841b169f1548f39899f9c8a15de9770d8531..0000000000000000000000000000000000000000 --- "a/work/com/java/minxi/java_20240603/java_2301_\345\256\213\345\207\257_2344310137/ladder.jsp" +++ /dev/null @@ -1,32 +0,0 @@ -<%@ page import="java.text.DecimalFormat" %> -<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> - - - 梯形 - - -<% - //获取梯形的上底,下底,高 - String topBaseStr = request.getParameter("topBase"); - String bottomBaseStr = request.getParameter("bottomBase"); - String heightStr = request.getParameter("height"); - - double topBase = Double.parseDouble(topBaseStr); - double bottomBase = Double.parseDouble(bottomBaseStr); - double height = Double.parseDouble(heightStr); - - //计算梯形面积 - double area = (topBase+bottomBase) * height / 2; - - //格式化输出 - DecimalFormat df = new DecimalFormat("#.00"); -%> -
-

梯形的面积

- 上底:<%= topBase %>
- 下底:<%= bottomBase %>
- 高:<%= height %>
- 面积:<%= df.format(area) %>
-
- - \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240604/java_2301_\351\203\255\345\260\217\347\207\225_2344310132/index10604.jsp" "b/work/com/java/minxi/java_20240604/java_2301_\351\203\255\345\260\217\347\207\225_2344310132/index10604.jsp" new file mode 100644 index 0000000000000000000000000000000000000000..eb61921c68b928fa6183f1126a45a86c7337f96b --- /dev/null +++ "b/work/com/java/minxi/java_20240604/java_2301_\351\203\255\345\260\217\347\207\225_2344310132/index10604.jsp" @@ -0,0 +1,96 @@ +<%@ page import="com.sun.tools.sjavac.pubapi.PubApi" %> +<%@ page import="java.security.PublicKey" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="java.sql.*" %> +<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> + + + 输出数据 +
+ +<% + //定义UserInfo类 + class UserInfo{ + int id; + String userName; + String userPhone; + + 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; + PreparedStatement preparedStatement = null; + ResultSet resultSet=null; + ArrayList userList = new ArrayList<>(); + + try { + //建立数据库连接 + //数据库连接参数 + String url = "jdbc:mysql://localhost:3306/student?serverTimezone=Asia/Shanghai"; + String username = "root"; + String password = "root"; + //加载并注册驱动 + Class.forName("com.mysql.cj.jdbc.Driver"); + //创建数据库连接 + connection = DriverManager.getConnection(url,username,password); + //创建Statement对象 + Statement statement = connection.createStatement(); + //执行sql查询 + String sql = "select id,user_name,user_phone from user_info"; + resultSet = statement.executeQuery(sql); + + //处理查询结果 + while (resultSet.next()){ + int id = resultSet.getInt("id"); + String userName = resultSet.getString("user_name"); + String userPhone = resultSet.getString("user_phone"); + + UserInfo user = new UserInfo(id,userName,userPhone); + userList.add(user); + } + out.print(userList); + }catch (Exception e){ + e.printStackTrace(); + }finally { + try { + if (null != preparedStatement) { + preparedStatement.close(); + } + if (null != resultSet) { + resultSet.close(); + } + if (null != connection) { + connection.close(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + // 输出List泛型对象中的数据 + + // 将userList存储到session中 +// session.setAttribute("UserList", userList); +// String user1 =(String) session.getAttribute("UserList"); +// String user2 = session.getAttribute("UserList").toString(); +%> + + + + + + + + \ No newline at end of file diff --git "a/work/com/java/minxi/java_20240604/java_2301_\351\203\255\345\260\217\347\207\225_2344310132/index20604.jsp" "b/work/com/java/minxi/java_20240604/java_2301_\351\203\255\345\260\217\347\207\225_2344310132/index20604.jsp" new file mode 100644 index 0000000000000000000000000000000000000000..bd15b322f3ee712ea56e0f1100b743e21bf0438d --- /dev/null +++ "b/work/com/java/minxi/java_20240604/java_2301_\351\203\255\345\260\217\347\207\225_2344310132/index20604.jsp" @@ -0,0 +1,36 @@ + +<%@ page import="java.util.List" %> +<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> + + + 获取数据 + + +<% + String a = request.getParameter("id"); + String b = request.getParameter("userName"); + String c = request.getParameter("userPhone"); +%> +

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

+

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

+

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

+<%--<%--%> +<%-- // 从session中获取userList--%> +<%-- List userList = (List) session.getAttribute("userList");--%> +<%-- if (userList != null) {--%> +<%-- for (UserInfo user : userList) {--%> +<%-- out.println(user.toString() + "
");--%> +<%-- }--%> +<%-- } else {--%> +<%-- out.println("No user information found.");--%> +<%-- }--%> +<%--%>--%> + + + \ No newline at end of file