wuheng 2 gadi atpakaļ
vecāks
revīzija
1fb301ef6e

+ 5 - 5
day05/pom.xml

@@ -23,12 +23,12 @@
         </dependency>
 <!--   单元测试组件   -->
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.13.2</version>
-        </dependency>
+        <groupId>junit</groupId>
+        <artifactId>junit</artifactId>
+        <version>4.13.2</version>
+    </dependency>
 
-<!--    日志组件    -->
+        <!--    日志组件    -->
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>

BIN
day16/JavaBean.pdf


BIN
day16/Maven复习.pdf


+ 21 - 0
day16/demo/pom.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>day16</artifactId>
+        <groupId>org.example</groupId>
+        <version>1.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>demo</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>

+ 46 - 32
day16/pom.xml

@@ -6,38 +6,52 @@
 
     <groupId>org.example</groupId>
     <artifactId>day16</artifactId>
+    <packaging>pom</packaging>
     <version>1.0</version>
+    <modules>
+        <module>demo</module>
+    </modules>
 
-    <dependencies>
-        <!--   数据库驱动    -->
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-            <version>8.0.30</version>
-        </dependency>
-        <!--    测试    -->
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.13.2</version>
-        </dependency>
-        <!--    日志组件    -->
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <version>1.7.20</version>
-        </dependency>
-        <!--    日志组件    -->
-        <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-classic</artifactId>
-            <version>1.2.3</version>
-        </dependency>
-        <!--   mybatis-plus     -->
-        <dependency>
-            <groupId>com.baomidou</groupId>
-            <artifactId>mybatis-plus</artifactId>
-            <version>3.1.0</version>
-        </dependency>
-    </dependencies>
+    <properties>
+        <mysql.version>8.0.30</mysql.version>
+        <junit.version>4.13.2</junit.version>
+        <slf4j.version>1.7.20</slf4j.version>
+        <logback.version>1.2.3</logback.version>
+        <mybatis.plus.version>3.1.0</mybatis.plus.version>
+    </properties>
+
+    <dependencyManagement>
+        <dependencies>
+            <!--   数据库驱动    -->
+            <dependency>
+                <groupId>mysql</groupId>
+                <artifactId>mysql-connector-java</artifactId>
+                <version>${mysql.version}</version>
+            </dependency>
+            <!--    测试    -->
+            <dependency>
+                <groupId>junit</groupId>
+                <artifactId>junit</artifactId>
+                <version>${junit.version}</version>
+            </dependency>
+            <!--    日志组件    -->
+            <dependency>
+                <groupId>org.slf4j</groupId>
+                <artifactId>slf4j-api</artifactId>
+                <version>${slf4j.version}</version>
+            </dependency>
+            <!--    日志组件    -->
+            <dependency>
+                <groupId>ch.qos.logback</groupId>
+                <artifactId>logback-classic</artifactId>
+                <version>${logback.version}</version>
+            </dependency>
+            <!--   mybatis-plus     -->
+            <dependency>
+                <groupId>com.baomidou</groupId>
+                <artifactId>mybatis-plus</artifactId>
+                <version>${mybatis.plus.version}</version>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
 </project>

+ 15 - 1
study/web/brand.jsp

@@ -10,7 +10,21 @@
 <body>
 <h1> ${sessionScope.user.username} 欢迎您</h1>
 <input style="width: 100px" type="button" value="新增" id="addbrand" ><br>
-<hr>
+<hr />
+
+<jsp:useBean id="MyBrand" class="com.lovecoding.study.domian.Brand" scope="page" ></jsp:useBean>
+<jsp:setProperty name="MyBrand" property="brandName" value="达利园" />
+<jsp:setProperty name="MyBrand" property="companyName" value="达利园食品有限公司" />
+
+<%--<jsp:getProperty name="MyBrand" property="brandName"/> <br />--%>
+
+<%--<%=MyBrand.getBrandName()%> <br />--%>
+
+可以解析: ${MyBrand.brandName}     <br />
+可以解析: ${MyBrand["brandName"]}  <br />
+不正确:  ${MyBrand[brandName]}   <br />
+
+<hr />
 <table border="1" cellspacing="0" width="80%">
     <tr>
         <th>序号</th>

+ 40 - 0
study/web/el.jsp

@@ -0,0 +1,40 @@
+<%--
+  Created by IntelliJ IDEA.
+  User: 武恒
+  Date: 2023/2/18
+  Time: 15:17
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<head>
+    <title>EL表达式</title>
+</head>
+<body>
+
+<h1> 运算符 </h1>
+<%
+int n = 100;
+int s = 10;
+request.setAttribute("n", n);
+request.setAttribute("s", s);
+%>
+<p>加法  ${ n + s }</p>
+<p>减法  ${ n - s }</p>
+<p>成法  ${ n * s }</p>
+<p>除法  ${ n / s }</p>
+<p>取模  ${ n % s }</p>
+
+<h1> 运算符 </h1>
+<p>比较运算 ==  ${ n == s }</p>
+<p>比较运算 !=  ${ n != s }</p>
+<p>大于 >  ${ n > s }</p>
+<p>小于 <  ${ s < n }</p>
+<p>三元运算符  ${ s < n ? "S 小于 n" : "s 大于 n" }</p>
+<p>判空运算符 empty  ${ empty s }</p>
+
+
+
+
+</body>
+</html>

+ 58 - 0
study/web/jstl.jsp

@@ -0,0 +1,58 @@
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%--
+  Created by IntelliJ IDEA.
+  User: 武恒
+  Date: 2023/2/18
+  Time: 15:31
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<head>
+    <title>JSTL 标签</title>
+</head>
+<body>
+
+<%
+    int n = 10;
+    String[] arr = {"苹果","鸭梨","香蕉","菠萝","桃子"};
+    request.setAttribute("n", n);
+    request.setAttribute("arr", arr);
+%>
+
+<div style="width: 600px; margin: 0 auto; height: 800px">
+    <h1> 循环遍历 </h1>
+    <c:forEach begin="0" end="${n}" var="var" >
+        ${var}
+    </c:forEach>
+    <h1> 循环数组 </h1>
+    <ul>
+    <c:forEach items="${arr}" var="var" >
+        <li>${var}</li>
+    </c:forEach>
+    </ul>
+    <h1> IF标签 </h1>
+    <%
+        //1 男生 2 女生
+        int sex = 1;
+        request.setAttribute("sex", sex);
+    %>
+    <c:if test="${sex == 1}" >
+        <span>张三是男生</span>
+    </c:if>
+    <c:if test="${sex > 1}" >
+        <span>张三是女生</span>
+    </c:if>
+    <h1> set标签 </h1>
+    <c:set var="name" value="张三" scope="page" />
+    <h5>${name}</h5>
+
+    <h1> when标签 </h1>
+    <c:choose>
+        <c:when test="${sex == 1}"><span>张三是男生</span></c:when>
+        <c:when test="${sex > 1}"><span>张三是女生</span></c:when>
+        <c:otherwise><span>张三不明生物</span></c:otherwise>
+    </c:choose>
+</div>
+</body>
+</html>

+ 2 - 1
study/web/login.jsp

@@ -10,7 +10,8 @@
 </head>
 <body>
 <div id="loginDiv" style="height: 350px">
-    <form action="${pageContext.servletContext.contextPath}/user" id="form" method="get">
+<%--    <form action="${pageContext.servletContext.contextPath}/user" id="form" method="get">--%>
+    <form action="property.jsp" id="form" method="get">
         <h1 id="loginMsg">LOGIN IN</h1>
 
         <div id="errorMsg">${sessionScope.error}</div>

+ 22 - 0
study/web/property.jsp

@@ -0,0 +1,22 @@
+<%--
+  Created by IntelliJ IDEA.
+  User: 武恒
+  Date: 2023/2/18
+  Time: 14:29
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<head>
+    <title>Bean对象自动赋值</title>
+</head>
+<body>
+
+    <jsp:useBean id="User" class="com.lovecoding.study.domian.User" />
+
+    <jsp:setProperty name="User" property="*" />
+
+    <%=User%>
+
+</body>
+</html>