From 0d3fe47b4e7dd7298a4b2a3ace2c48ac223f8bb7 Mon Sep 17 00:00:00 2001 From: 1638894223 <1638894223@qq.com> Date: Wed, 3 Apr 2024 20:15:30 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 125 ++++++++++ src/main/java/com/dao/IBaseDao.java | 72 ++++++ src/main/java/com/dao/ISysCustomerDao.java | 23 ++ src/main/java/com/dao/impl/BaseDaoImpl.java | 80 +++++++ .../com/dao/impl/ISysCustomerDaoImpl.java | 225 ++++++++++++++++++ src/main/java/com/entity/SysCustomer.java | 86 +++++++ .../java/com/servlet/CustomerServlet.java | 177 ++++++++++++++ src/main/java/com/utils/DBTools.java | 86 +++++++ src/main/java/com/utils/JDBC.java | 70 ++++++ src/main/java/com/utils/ReflectionUtils.java | 179 ++++++++++++++ src/main/webapp/META-INF/MANIFEST.MF | 3 + src/main/webapp/WEB-INF/web.xml | 8 + src/main/webapp/customer.jsp | 52 ++++ src/main/webapp/customerAll.jsp | 36 +++ src/main/webapp/customerEdit.jsp | 30 +++ src/main/webapp/customerResult.jsp | 17 ++ src/main/webapp/index.jsp | 16 ++ src/test/java/com/TestP.java | 18 ++ src/test/java/com/dao/T2.java | 19 ++ web/WEB-INF/web.xml | 6 + 20 files changed, 1328 insertions(+) create mode 100644 pom.xml create mode 100644 src/main/java/com/dao/IBaseDao.java create mode 100644 src/main/java/com/dao/ISysCustomerDao.java create mode 100644 src/main/java/com/dao/impl/BaseDaoImpl.java create mode 100644 src/main/java/com/dao/impl/ISysCustomerDaoImpl.java create mode 100644 src/main/java/com/entity/SysCustomer.java create mode 100644 src/main/java/com/servlet/CustomerServlet.java create mode 100644 src/main/java/com/utils/DBTools.java create mode 100644 src/main/java/com/utils/JDBC.java create mode 100644 src/main/java/com/utils/ReflectionUtils.java create mode 100644 src/main/webapp/META-INF/MANIFEST.MF create mode 100644 src/main/webapp/WEB-INF/web.xml create mode 100644 src/main/webapp/customer.jsp create mode 100644 src/main/webapp/customerAll.jsp create mode 100644 src/main/webapp/customerEdit.jsp create mode 100644 src/main/webapp/customerResult.jsp create mode 100644 src/main/webapp/index.jsp create mode 100644 src/test/java/com/TestP.java create mode 100644 src/test/java/com/dao/T2.java create mode 100644 web/WEB-INF/web.xml diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..b3fb93c --- /dev/null +++ b/pom.xml @@ -0,0 +1,125 @@ + + + + 4.0.0 + + com.bjpowernode + Customer + 1.0-SNAPSHOT + war + + + + + junit + junit + 4.12 + test + + + + javax.servlet + javax.servlet-api + 4.0.1 + provided + + + + javax.servlet.jsp + jsp-api + 2.1.3-b06 + provided + + + + org.mybatis + mybatis + 3.4.5 + + + + javax.servlet + jstl + 1.2 + + + + com.fasterxml.jackson.core + jackson-core + 2.0.1 + + + + com.fasterxml.jackson.core + jackson-databind + 2.0.0 + + + + mysql + mysql-connector-java + 8.0.15 + + + + + + + + + log4j + log4j + 1.2.17 + + + + + commons-dbutils + commons-dbutils + 1.7 + + + + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.3.1 + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + + + com.servlet.CustomerServlet + + + + + + + + + + + + UTF-8 + 17 + 17 + + + diff --git a/src/main/java/com/dao/IBaseDao.java b/src/main/java/com/dao/IBaseDao.java new file mode 100644 index 0000000..316af3f --- /dev/null +++ b/src/main/java/com/dao/IBaseDao.java @@ -0,0 +1,72 @@ +package com.dao; + +import java.sql.Connection; +import java.sql.SQLException; +import java.util.List; + + +public interface IBaseDao{ + + /** + * 批量处理的方法 + * @param conn + * @param sql + * @param params: 填充占位符的 Object [] 类型的可变参数. + * @throws SQLException + */ + void batch(Connection conn, String sql, Object [] ... params) throws SQLException; + + /** + * 返回具体的一个值, 例如总人数, 平均工资, 某一个人的 email 等. + * @param conn + * @param sql + * @param params + * @return + * @throws SQLException + */ + E getForValue(Connection conn,String sql, Object ... params) throws SQLException; + + /** + * 返回 T 的一个集合 + * @param conn + * @param sql + * @param params + * @return + * @throws SQLException + */ + List getForList(Connection conn,String sql,Object ...params)throws SQLException; + + /** + * 返回一个 T 的对象 + * @param conn + * @param sql + * @param params + * @return + * @throws SQLException + */ + T get(Connection conn,String sql,Object ...params)throws SQLException; + + /** + * 用于UPDATE, DELETE等更新操作,返回受影响的行数 + * @param conn: 数据库连接 + * @param sql: SQL 语句 + * @param params: 填充占位符的可变参数. + * return 返回受影响的行数 + * @throws SQLException + * + */ + int update(Connection conn,String sql,Object ...params)throws SQLException; + + /** + * 用于新增记录并返回新纪录的id值 + * @param conn + * @param sql + * @param params + * @return + * @throws SQLException + */ + int insert(Connection conn,String sql,Object ...params)throws SQLException; + +} + + diff --git a/src/main/java/com/dao/ISysCustomerDao.java b/src/main/java/com/dao/ISysCustomerDao.java new file mode 100644 index 0000000..c18c839 --- /dev/null +++ b/src/main/java/com/dao/ISysCustomerDao.java @@ -0,0 +1,23 @@ +package com.dao; + +import java.util.List; + +import com.entity.SysCustomer; + +public interface ISysCustomerDao { + // executeQuery,executeUpdate + int add(String loginName, String realName, String password, String roleId); + int delete(String id); + int edit(String id, String loginName, String realName); + List getAll(); + + // 原始方式 + int add(String loginName, String realName, String password, int roleId); + int delete(int id); + int edit(int id, String loginName, String realName); + List getAlls(); + + SysCustomer get(int id); + SysCustomer get(String id); + +} diff --git a/src/main/java/com/dao/impl/BaseDaoImpl.java b/src/main/java/com/dao/impl/BaseDaoImpl.java new file mode 100644 index 0000000..128dfb4 --- /dev/null +++ b/src/main/java/com/dao/impl/BaseDaoImpl.java @@ -0,0 +1,80 @@ +package com.dao.impl; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.List; + +import org.apache.commons.dbutils.QueryRunner; +import org.apache.commons.dbutils.handlers.BeanHandler; +import org.apache.commons.dbutils.handlers.BeanListHandler; +import org.apache.commons.dbutils.handlers.ScalarHandler; + +import com.dao.IBaseDao; +import com.utils.ReflectionUtils; + +/** + * 使用 QueryRunner 提供其具体的实现 + * @param : 子类需传入的泛型类型. + */ +public class BaseDaoImpl implements IBaseDao { + + private QueryRunner queryRunner=null; + + public Class type; + + public BaseDaoImpl(){ + queryRunner=new QueryRunner(); + type=ReflectionUtils.getSuperGenericType(getClass()); + } + + @Override + public void batch(Connection conn, String sql, Object[]... params) + throws SQLException { + queryRunner.batch(conn, sql, params); + + } + + @Override + public E getForValue(Connection conn, String sql, Object... params) + throws SQLException { + return queryRunner.query(conn, sql, new ScalarHandler<>(), params); + } + + @Override + public List getForList(Connection conn, String sql, Object... params) + throws SQLException { + return queryRunner.query(conn, sql, new BeanListHandler<>(type), params); + } + + @Override + public T get(Connection conn, String sql, Object... params) + throws SQLException { + return queryRunner.query(conn, sql, new BeanHandler<>(type), params); + } + + @Override + public int update(Connection conn, String sql, Object... params) + throws SQLException { + return queryRunner.update(conn, sql, params); + } + + @Override + public int insert(Connection conn, String sql, Object... params) throws SQLException { + int newId = -1; + PreparedStatement st = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); + if (params != null && params.length > 0) { + for (int i = 0; i < params.length; i++) { + st.setObject(i + 1, params[i]); + } + } + st.executeUpdate(); + ResultSet rs = st.getGeneratedKeys(); + while(rs.next()){ + newId = rs.getInt(1); + } + return newId; + } +} diff --git a/src/main/java/com/dao/impl/ISysCustomerDaoImpl.java b/src/main/java/com/dao/impl/ISysCustomerDaoImpl.java new file mode 100644 index 0000000..5a1d1c3 --- /dev/null +++ b/src/main/java/com/dao/impl/ISysCustomerDaoImpl.java @@ -0,0 +1,225 @@ +package com.dao.impl; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.sql.PreparedStatement; +import com.dao.ISysCustomerDao; +import com.entity.SysCustomer; + + +public class ISysCustomerDaoImpl extends BaseDaoImpl implements ISysCustomerDao { + + // 1 数据库驱动类 + static String driver = "com.mysql.cj.jdbc.Driver"; + // 2 数据库的连接串 + // String url = "jdbc:mysql://localhost:3306/guestbook"; + static String url = "jdbc:mysql://localhost:3306/spring_db?serverTimezone=UTC&useSSL=false"; + // 3 用户名 + static String user = "root"; + // 4 密码 + static String password = "cn204432051"; + + private static Connection getConnection() { + + Connection conn = null; + try { + Class.forName(driver); // classLoader,加载对应驱动 + conn = DriverManager.getConnection(url, user, password); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (SQLException e) { + e.printStackTrace(); + } + return conn; + } + + private static Connection conn = getConnection(); + + // 增 executeUpdate + public int add(String loginName, String realName, String password, String roleId) { + int ret = -1; + + PreparedStatement pst = null; + String sql = "insert into tuser(loginName, realName, password, roleId)values(?,?,?,?)"; + try { + pst = (PreparedStatement) conn.prepareStatement(sql); + + // 赋值 + pst.setString(1, loginName); + pst.setString(2, realName); + pst.setString(3, password); + pst.setString(4, roleId); + + // 执行 + ret = pst.executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } + return ret; + } + + // 删 executeUpdate + public int delete(String id) { + int ret = -1; + String sql = "delete from tuser where id = ?"; + PreparedStatement pst = null; + try { + pst = (PreparedStatement) conn.prepareStatement(sql); + pst.setString(1, id); + + // 执行 + ret = pst.executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } + return ret; + } + + // 改前取值 executeUpdate + @Override + public SysCustomer get(String id) { + SysCustomer customer = null; + String sql = "select * from tuser where id = ?"; + PreparedStatement pst = null; + ResultSet rs = null; + try { + pst = (PreparedStatement) conn.prepareStatement(sql); + pst.setString(1, id); + rs = pst.executeQuery(); + + while (rs.next()) { + customer = new SysCustomer(); + customer.setId(rs.getInt("id")); + customer.setLoginName(rs.getString("loginName")); + customer.setRealName(rs.getString("realName")); + customer.setPassword(rs.getString("password")); + customer.setRoleId(Integer.valueOf(rs.getString("roleId"))); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return customer; + } + + // 改 executeUpdate + public int edit(String id, String loginName, String realName) { + int ret = -1; + String sql = "update tuser set loginName=?, realName=? where id=?"; + PreparedStatement pst = null; + try { + pst = (PreparedStatement) conn.prepareStatement(sql); + pst.setString(3, id); + pst.setString(2, loginName); + pst.setString(1, realName); + + ret = pst.executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } + return ret; + } + + // 查 executeQuery + public List getAll() { + String sql = "select * from tuser"; + List list = new ArrayList(); + + PreparedStatement pst = null; + ResultSet rs = null; + try { + pst = (PreparedStatement) conn.prepareStatement(sql); + rs = pst.executeQuery(); + + SysCustomer customer = null; + while (rs.next()) { + customer = new SysCustomer(); + customer.setId(rs.getInt("id")); + customer.setLoginName(rs.getString("loginName")); + customer.setRealName(rs.getString("realName")); + customer.setPassword(rs.getString("password")); + customer.setRoleId(Integer.valueOf(rs.getString("roleId"))); + list.add(customer); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return list; + } + + /* + * ----------------------------------------- + */ + // 增 + @Override + public int add(String loginName, String realName, String password, int roleId) { + int ret = -1; + String sql = "insert into tuser(loginName, realName, password, roleId)values(?,?,?,?)"; + Object[] params = new Object[] { loginName, realName, password, roleId }; + try { + ret = super.insert(conn, sql, params); + } catch (SQLException e1) { + e1.printStackTrace(); + } + return ret; + } + + // 删 + @Override + public int delete(int id) { + int ret = -1; + String sql = "delete from tuser where id = ?"; + Object[] params = new Object[] { id }; + try { + ret = super.update(conn, sql, params); + } catch (SQLException e1) { + e1.printStackTrace(); + } + return ret; + } + + // 改前取值 + @Override + public SysCustomer get(int id) { + SysCustomer sysCustomer = null; + String sql = "select * from tuser where id = ?"; + Object[] params = new Object[] { id }; + try { + sysCustomer = super.get(conn, sql, params); + } catch (SQLException e) { + e.printStackTrace(); + } + return sysCustomer; + } + + // 改 + @Override + public int edit(int id, String loginName, String realName) { + int ret = -1; + String sql = "update tuser set loginName=?, realName=? where id=?"; + Object[] params = new Object[] { loginName, realName, id }; + try { + ret = super.update(conn, sql, params); + } catch (SQLException e1) { + e1.printStackTrace(); + } + return ret; + } + + // 查 + @Override + public List getAlls() { + List list = null; + String sql = "select * from tuser"; + Object[] params = new Object[] {}; + try { + list = super.getForList(conn, sql, params); + } catch (SQLException e) { + e.printStackTrace(); + } + return list; + } +} diff --git a/src/main/java/com/entity/SysCustomer.java b/src/main/java/com/entity/SysCustomer.java new file mode 100644 index 0000000..c49111a --- /dev/null +++ b/src/main/java/com/entity/SysCustomer.java @@ -0,0 +1,86 @@ +package com.entity; + +import java.io.Serializable; + +public class SysCustomer implements Serializable { + + private static final long serialVersionUID = 1L; + + // 主键 + private int id; + // 登录名称 + private String loginName; + // 真实姓名 + private String realName; + // 密码 + private String password; + // 角色编号 + private int roleId; + + public SysCustomer() { + super(); + } + + public SysCustomer(String loginName, String realName, String password, int roleId) { + super(); + this.loginName = loginName; + this.realName = realName; + this.password = password; + this.roleId = roleId; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getLoginName() { + return loginName; + } + + public void setLoginName(String loginName) { + this.loginName = loginName; + } + + public String getRealName() { + return realName; + } + + public void setRealName(String realName) { + this.realName = realName; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public int getRoleId() { + return roleId; + } + + public String getRoleIds() { + String roleIds = "" + roleId; + return roleIds; + } + + public void setRoleId(int roleId) { + this.roleId = roleId; + } + + public static long getSerialversionuid() { + return serialVersionUID; + } + + @Override + public String toString() { + return "SysCustomer [id=" + id + ", loginName=" + loginName + ", realName=" + realName + ", password=" + + password + ", roleId=" + roleId + "]"; + } +} diff --git a/src/main/java/com/servlet/CustomerServlet.java b/src/main/java/com/servlet/CustomerServlet.java new file mode 100644 index 0000000..8a6abfa --- /dev/null +++ b/src/main/java/com/servlet/CustomerServlet.java @@ -0,0 +1,177 @@ +package com.servlet; + +import java.io.IOException; +import java.util.List; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.dao.ISysCustomerDao; +import com.dao.impl.ISysCustomerDaoImpl; +import com.entity.SysCustomer; + + + +@WebServlet("/customerServlet.do") +public class CustomerServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + private ISysCustomerDao customerDao = new ISysCustomerDaoImpl(); + + public CustomerServlet() { + super(); + } + + + + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + + // 乱码处理 + request.setCharacterEncoding("utf-8"); + response.setContentType("text/html; charset=utf-8"); + response.setCharacterEncoding("utf-8"); + + + + // 获取jsp页面参数值 + String type = request.getParameter("type"); + String id = request.getParameter("id"); + String loginName = request.getParameter("loginName"); + String realName = request.getParameter("realName"); + String password = request.getParameter("password"); +// String confirmPassword = request.getParameter("confirmPassword"); +// String roleId = request.getParameter("roleId"); + String confirmPassword = password; + String roleId ="1"; + request.setCharacterEncoding("utf-8"); + + + + + if (type.equals("add")) { + // 增 + add(request, response, loginName, realName, password, confirmPassword, roleId); + } else if (type.equals("delete")) { + // 删 + delete(request, response, id); + } else if (type.equals("get")) { + // 改前获取值 - 跳编辑页面 + get(request, response, id); + } else if (type.equals("edit")) { + // 改 + edit(request, response, id, loginName, realName); + } else if (type.equals("getAll")) { + // 查 + getAll(request, response); + } + } + + // 增 + private void add(HttpServletRequest request, HttpServletResponse response, String loginName, String realName, + String password, String confirmPassword, String roleId) throws ServletException, IOException { + + request.setCharacterEncoding("utf-8"); + response.setContentType("text/html; charset=utf-8"); + response.setCharacterEncoding("utf-8"); + + if (loginName.equals("") || realName.equals("") || password.equals("") || roleId.equals("") + || !(password.equals(confirmPassword))) { + request.setAttribute("reg", "failed"); + } else { + // Dao 层添加 + // 使用 executeUpdate + this.customerDao.add(loginName, realName, password, roleId); + // 使用 insert +// this.customerDao.add(loginName, realName, password, Integer.valueOf(roleId)); + + // 返回jsp页面消息 + request.setAttribute("reg", "successful"); + } + // 跳转 - 结果页面 + request.getRequestDispatcher("/customerResult.jsp").forward(request, response); + } + + // 删 + private void delete(HttpServletRequest request, HttpServletResponse response, String id) throws ServletException, IOException { + // 使用 executeUpdate + int ret = this.customerDao.delete(id); + request.setCharacterEncoding("utf-8"); + response.setContentType("text/html; charset=utf-8"); + response.setCharacterEncoding("utf-8"); + // 使用 update +// int ret = this.customerDao.delete(Integer.valueOf(id)); + + if (ret == 1) { + request.setAttribute("reg", "successful"); + } else { + request.setAttribute("reg", "failed"); + } + // 跳转 - 结果页面 + request.getRequestDispatcher("/customerResult.jsp").forward(request, response); + } + + // 改前获取值 - 跳编辑页面 + private void get(HttpServletRequest request, HttpServletResponse response, String id) throws ServletException, IOException { + // 使用 executeQuery + SysCustomer customer = this.customerDao.get(id); + // 使用 get +// SysCustomer customer = this.customerDao.get(Integer.valueOf(id)); + request.setCharacterEncoding("utf-8"); + response.setContentType("text/html; charset=utf-8"); + response.setCharacterEncoding("utf-8"); + request.setAttribute("customer", customer); + System.out.println(customer); + // 跳转 + request.getRequestDispatcher("/customerEdit.jsp").forward(request, response); + } + + // 改 + private void edit(HttpServletRequest request, HttpServletResponse response, String id, String loginName, String realName) throws ServletException, IOException { + request.setCharacterEncoding("utf-8"); + response.setContentType("text/html; charset=utf-8"); + response.setCharacterEncoding("utf-8"); + System.out.println(loginName); + System.out.println(realName); + if (loginName.equals("") || realName.equals("")) { + // 返回jsp页面消息 + request.setAttribute("reg", "failed"); + } else { + // Dao 层修改 + // 使用 executeUpdate + this.customerDao.edit(id, realName,loginName); + // 使用 update +// this.customerDao.edit(Integer.valueOf(id), loginName, realName); + + // 返回jsp页面消息 + request.setAttribute("reg", "successful"); + } + // 跳转 - 结果页面 + request.getRequestDispatcher("/customerResult.jsp").forward(request, response); + } + + // 查 + private void getAll(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // 获取数据库表中全部数据 + // 使用 executeQuery + request.setCharacterEncoding("utf-8"); + response.setContentType("text/html; charset=utf-8"); + response.setCharacterEncoding("utf-8"); + List customerList = this.customerDao.getAll(); + // 使用 getForList +// List customerList = this.customerDao.getAlls(); + request.setAttribute("customerList", customerList); + + // 跳转 - 列表页面 + request.getRequestDispatcher("/customerAll.jsp").forward(request, response); + } + + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + doGet(request, response); + } +} \ No newline at end of file diff --git a/src/main/java/com/utils/DBTools.java b/src/main/java/com/utils/DBTools.java new file mode 100644 index 0000000..d3b87e3 --- /dev/null +++ b/src/main/java/com/utils/DBTools.java @@ -0,0 +1,86 @@ +package com.utils; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +/** + * 功能: + * 1 提供数据连接 + * 2 关闭数据库资源 + * @author Administrator + * + */ +public class DBTools { + + // 要实现数据库访问操作,首选需要4个基本信息 + // 1 数据库驱动类 + static String driver = "com.mysql.jdbc.Driver"; + // 2 数据库的连接串 + // String url = "jdbc:mysql://localhost:3306/guestbook"; + static String url = "jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC"; + // 3 用户名 + static String user = "root"; + // 4 密码 + static String password = "root"; + + // 加载数据库驱动 + static { + try { + Class.forName(driver); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } + + /** + * 获取数据库连接对象 + * @return + */ + public static Connection getConnection() { + Connection conn = null; + try { + conn = DriverManager.getConnection(url, user, password); + } catch (SQLException e) { + e.printStackTrace(); + } + return conn; + } + + /** + * 关闭数据库资源 + * @param conn + * @param st + * @param rs + */ + public static void close(Connection conn, Statement st, ResultSet rs) { + if(rs!=null) { + try { + rs.close(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + if(st != null) { + try { + st.close(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + if(conn != null) { + try { + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + } + } + } + public static void main(String[] args) { + System.out.println(DBTools.getConnection()); + } +} diff --git a/src/main/java/com/utils/JDBC.java b/src/main/java/com/utils/JDBC.java new file mode 100644 index 0000000..02e2895 --- /dev/null +++ b/src/main/java/com/utils/JDBC.java @@ -0,0 +1,70 @@ +package com.utils; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +//public class JDBC { +// // 要实现数据库访问操作,首选需要4个基本信息 +// // 1 数据库驱动类 +// static String driver = "com.mysql.jdbc.Driver"; +// // 2 数据库的连接串 +// // String url = "jdbc:mysql://localhost:3306/guestbook"; +// static String url = "jdbc:mysql://localhost:3306/spring_db?serverTimezone=UTC&useSSL=false"; +// +// // 3 用户名 +// static String user = "root"; +// // 4 密码 +// static String password = "root"; +// +// // 加载数据库驱动 +// static { +// try { +// Class.forName(driver); +// } catch (ClassNotFoundException e) { +// e.printStackTrace(); +// } +// } +// +// public static Connection getConnection() { +// Connection conn = null; +// try { +// conn = DriverManager.getConnection(url, user, password); +// } catch (SQLException e) { +// e.printStackTrace(); +// } +// return conn; +// } +//} +public class JDBC { + + static { + try { + + Class.forName("com.mysql.cj.jdbc.Driver"); + } catch (ClassNotFoundException e) { + + e.printStackTrace(); + } + } + //加载驱动 + //Class.forName("com.mysql.cj.jdbc.Driver"); + //提供连接基本信息 + static String url = "jdbc:mysql://localhost:3306/spring_db?serverTimezone=UTC&useSSL=false"; + static String user = "root"; + static String password = "cn204432051"; + //获取连接 + public static Connection getConnection() { + Connection conn = null; + try { + conn= DriverManager.getConnection(url,user,password); + }catch (SQLException e){ + e.printStackTrace(); + } + return conn; + } + + + + + +} \ No newline at end of file diff --git a/src/main/java/com/utils/ReflectionUtils.java b/src/main/java/com/utils/ReflectionUtils.java new file mode 100644 index 0000000..3addd41 --- /dev/null +++ b/src/main/java/com/utils/ReflectionUtils.java @@ -0,0 +1,179 @@ +package com.utils; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; + +/** + * 反射的 Utils 函数集合 提供访问私有变量, 获取泛型类型 Class, 提取集合中元素属性等 Utils 函数 + * + * @author Administrator + * + */ +public class ReflectionUtils { + + + @SuppressWarnings("rawtypes") + public static Class getSuperClassGenricType(Class clazz, int index) { + Type genType = clazz.getGenericSuperclass(); + + if (!(genType instanceof ParameterizedType)) { + return Object.class; + } + + Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); + + if (index >= params.length || index < 0) { + return Object.class; + } + + if (!(params[index] instanceof Class)) { + return Object.class; + } + + return (Class) params[index]; + } + + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public static Class getSuperGenericType(Class clazz) { + return getSuperClassGenricType(clazz, 0); + } + + /** + * 循环向上转型, 获取对象的 DeclaredMethod + * + * @param object + * @param methodName + * @param parameterTypes + * @return + */ + public static Method getDeclaredMethod(Object object, String methodName, Class[] parameterTypes) { + + for (Class superClass = object.getClass(); superClass != Object.class; superClass = superClass + .getSuperclass()) { + try { + // superClass.getMethod(methodName, parameterTypes); + return superClass.getDeclaredMethod(methodName, parameterTypes); + } catch (NoSuchMethodException e) { + // Method 不在当前类定义, 继续向上转型 + } + // .. + } + + return null; + } + + /** + * 使 filed 变为可访问 + * + * @param field + */ + public static void makeAccessible(Field field) { + if (!Modifier.isPublic(field.getModifiers())) { + field.setAccessible(true); + } + } + + /** + * 循环向上转型, 获取对象的 DeclaredField + * + * @param object + * @param filedName + * @return + */ + public static Field getDeclaredField(Object object, String filedName) { + + for (Class superClass = object.getClass(); superClass != Object.class; superClass = superClass + .getSuperclass()) { + try { + return superClass.getDeclaredField(filedName); + } catch (NoSuchFieldException e) { + // Field 不在当前类定义, 继续向上转型 + } + } + return null; + } + + /** + * 直接调用对象方法, 而忽略修饰符(private, protected) + * + * @param object + * @param methodName + * @param parameterTypes + * @param parameters + * @return + * @throws InvocationTargetException + * @throws IllegalArgumentException + */ + public static Object invokeMethod(Object object, String methodName, Class[] parameterTypes, Object[] parameters) + throws InvocationTargetException { + + Method method = getDeclaredMethod(object, methodName, parameterTypes); + + if (method == null) { + throw new IllegalArgumentException("Could not find method [" + methodName + "] on target [" + object + "]"); + } + + method.setAccessible(true); + + try { + return method.invoke(object, parameters); + } catch (IllegalAccessException e) { + System.out.println("不可能抛出的异常"); + } + + return null; + } + + /** + * 直接设置对象属性值, 忽略 private/protected 修饰符, 也不经过 setter + * + * @param object + * @param fieldName + * @param value + */ + public static void setFieldValue(Object object, String fieldName, Object value) { + Field field = getDeclaredField(object, fieldName); + + if (field == null) + throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + object + "]"); + + makeAccessible(field); + + try { + field.set(object, value); + } catch (IllegalAccessException e) { + System.out.println("不可能抛出的异常"); + } + } + + /** + * 直接读取对象的属性值, 忽略 private/protected 修饰符, 也不经过 getter + * + * @param object + * @param fieldName + * @return + */ + public static Object getFieldValue(Object object, String fieldName) { + Field field = getDeclaredField(object, fieldName); + + if (field == null) + throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + object + "]"); + + makeAccessible(field); + + Object result = null; + + try { + result = field.get(object); + } catch (IllegalAccessException e) { + System.out.println("不可能抛出的异常"); + } + + return result; + } +} diff --git a/src/main/webapp/META-INF/MANIFEST.MF b/src/main/webapp/META-INF/MANIFEST.MF new file mode 100644 index 0000000..254272e --- /dev/null +++ b/src/main/webapp/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..73e9c61 --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,8 @@ + + + javaWebendtest + + customer.jsp + index.html + + \ No newline at end of file diff --git a/src/main/webapp/customer.jsp b/src/main/webapp/customer.jsp new file mode 100644 index 0000000..799bc32 --- /dev/null +++ b/src/main/webapp/customer.jsp @@ -0,0 +1,52 @@ +<%@ page language="java" contentType="text/html; charset=utf-8" + pageEncoding="utf-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + + +customer + + + +
+ + + + + + + + + + + + + +<%-- --%> +<%-- --%> +<%-- --%> +<%-- --%> +<%-- --%> +<%-- --%> +<%-- --%> +<%-- --%> + + + +
昵称
账号
密码
确认密码
所属角色--%> +<%-- --%> +<%--
+ +
+
+ + \ No newline at end of file diff --git a/src/main/webapp/customerAll.jsp b/src/main/webapp/customerAll.jsp new file mode 100644 index 0000000..7a696d7 --- /dev/null +++ b/src/main/webapp/customerAll.jsp @@ -0,0 +1,36 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + + + + + 添加 + + + + + + + + + + + + + + + + + + + +
序号昵称账号操作
${obj.id}${obj.loginName}${obj.realName} + 编辑 + 删除 +
+ + \ No newline at end of file diff --git a/src/main/webapp/customerEdit.jsp b/src/main/webapp/customerEdit.jsp new file mode 100644 index 0000000..582c4b5 --- /dev/null +++ b/src/main/webapp/customerEdit.jsp @@ -0,0 +1,30 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + + + + +
+ + + + + + + + + + + + + +
昵称
账号
+
+ + \ No newline at end of file diff --git a/src/main/webapp/customerResult.jsp b/src/main/webapp/customerResult.jsp new file mode 100644 index 0000000..69118a5 --- /dev/null +++ b/src/main/webapp/customerResult.jsp @@ -0,0 +1,17 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + + + + + +添加结果 + + +

${reg}

+ 返回 + + \ No newline at end of file diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp new file mode 100644 index 0000000..32a3f4c --- /dev/null +++ b/src/main/webapp/index.jsp @@ -0,0 +1,16 @@ +<%-- + Created by IntelliJ IDEA. + User: lsjss + Date: 2021/1/16 + Time: 20:02 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + $Title$ + + + $END$ + + diff --git a/src/test/java/com/TestP.java b/src/test/java/com/TestP.java new file mode 100644 index 0000000..ea25804 --- /dev/null +++ b/src/test/java/com/TestP.java @@ -0,0 +1,18 @@ +package com; + +import com.utils.JDBC; +import org.junit.Test; + +import java.sql.Connection; + +public class TestP { + @Test + public void testP(){ + Connection con= JDBC.getConnection(); + if(con!=null){ + System.out.println("mysql success"); + }else { + System.out.println("mysql err"); + } + } +} diff --git a/src/test/java/com/dao/T2.java b/src/test/java/com/dao/T2.java new file mode 100644 index 0000000..8b34790 --- /dev/null +++ b/src/test/java/com/dao/T2.java @@ -0,0 +1,19 @@ +package com.dao; + + +import com.utils.JDBC; +import org.junit.Test; + +import java.sql.Connection; + +public class T2 { + @Test + public void testP(){ + Connection con= JDBC.getConnection(); + if(con!=null){ + System.out.println("mysql success"); + }else { + System.out.println("mysql err"); + } + } +} diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml new file mode 100644 index 0000000..d80081d --- /dev/null +++ b/web/WEB-INF/web.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file -- Gitee From 2fc95f8c09ccc6dbdd3122bf01feb7d135ad1004 Mon Sep 17 00:00:00 2001 From: 1638894223 <1638894223@qq.com> Date: Thu, 4 Apr 2024 10:47:36 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 +++ .idea/artifacts/web_framework_war.xml | 16 ++++++ .../artifacts/web_framework_war_exploded.xml | 35 +++++++++++++ .idea/compiler.xml | 16 ++++++ .idea/encodings.xml | 6 +++ .idea/jarRepositories.xml | 20 +++++++ ...jackson_core_jackson_annotations_2_0_0.xml | 13 +++++ ...terxml_jackson_core_jackson_core_2_0_1.xml | 13 +++++ ...ml_jackson_core_jackson_databind_2_0_0.xml | 13 +++++ ...om_google_protobuf_protobuf_java_3_6_1.xml | 13 +++++ ...n__commons_dbutils_commons_dbutils_1_7.xml | 13 +++++ .../Maven__javax_el_el_api_2_1_2_b05.xml | 13 +++++ ..._javax_servlet_javax_servlet_api_4_0_1.xml | 13 +++++ ...n__javax_servlet_jsp_jsp_api_2_1_3_b06.xml | 13 +++++ .../Maven__javax_servlet_jstl_1_2.xml | 13 +++++ .idea/libraries/Maven__junit_junit_4_12.xml | 13 +++++ .idea/libraries/Maven__log4j_log4j_1_2_17.xml | 13 +++++ ...ven__mysql_mysql_connector_java_8_0_15.xml | 13 +++++ ...n__org_glassfish_javax_servlet_3_0_b70.xml | 13 +++++ .../Maven__org_hamcrest_hamcrest_core_1_3.xml | 13 +++++ .../Maven__org_mybatis_mybatis_3_4_5.xml | 13 +++++ .idea/misc.xml | 16 ++++++ .idea/modules.xml | 8 +++ .idea/runConfigurations.xml | 10 ++++ .idea/vcs.xml | 6 +++ .idea/web-framework.iml | 44 ++++++++++++++++ .../META-INF/MANIFEST.MF | 3 ++ target/Customer-1.0-SNAPSHOT/WEB-INF/web.xml | 8 +++ target/Customer-1.0-SNAPSHOT/customer.jsp | 52 +++++++++++++++++++ target/Customer-1.0-SNAPSHOT/customerAll.jsp | 36 +++++++++++++ target/Customer-1.0-SNAPSHOT/customerEdit.jsp | 30 +++++++++++ .../Customer-1.0-SNAPSHOT/customerResult.jsp | 17 ++++++ target/Customer-1.0-SNAPSHOT/index.jsp | 16 ++++++ 33 files changed, 542 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/artifacts/web_framework_war.xml create mode 100644 .idea/artifacts/web_framework_war_exploded.xml create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_0_0.xml create mode 100644 .idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_0_1.xml create mode 100644 .idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_0_0.xml create mode 100644 .idea/libraries/Maven__com_google_protobuf_protobuf_java_3_6_1.xml create mode 100644 .idea/libraries/Maven__commons_dbutils_commons_dbutils_1_7.xml create mode 100644 .idea/libraries/Maven__javax_el_el_api_2_1_2_b05.xml create mode 100644 .idea/libraries/Maven__javax_servlet_javax_servlet_api_4_0_1.xml create mode 100644 .idea/libraries/Maven__javax_servlet_jsp_jsp_api_2_1_3_b06.xml create mode 100644 .idea/libraries/Maven__javax_servlet_jstl_1_2.xml create mode 100644 .idea/libraries/Maven__junit_junit_4_12.xml create mode 100644 .idea/libraries/Maven__log4j_log4j_1_2_17.xml create mode 100644 .idea/libraries/Maven__mysql_mysql_connector_java_8_0_15.xml create mode 100644 .idea/libraries/Maven__org_glassfish_javax_servlet_3_0_b70.xml create mode 100644 .idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml create mode 100644 .idea/libraries/Maven__org_mybatis_mybatis_3_4_5.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/runConfigurations.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/web-framework.iml create mode 100644 target/Customer-1.0-SNAPSHOT/META-INF/MANIFEST.MF create mode 100644 target/Customer-1.0-SNAPSHOT/WEB-INF/web.xml create mode 100644 target/Customer-1.0-SNAPSHOT/customer.jsp create mode 100644 target/Customer-1.0-SNAPSHOT/customerAll.jsp create mode 100644 target/Customer-1.0-SNAPSHOT/customerEdit.jsp create mode 100644 target/Customer-1.0-SNAPSHOT/customerResult.jsp create mode 100644 target/Customer-1.0-SNAPSHOT/index.jsp diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/artifacts/web_framework_war.xml b/.idea/artifacts/web_framework_war.xml new file mode 100644 index 0000000..aaccbfc --- /dev/null +++ b/.idea/artifacts/web_framework_war.xml @@ -0,0 +1,16 @@ + + + $PROJECT_DIR$/target + + + false + web-framework + war + false + + + + + + + \ No newline at end of file diff --git a/.idea/artifacts/web_framework_war_exploded.xml b/.idea/artifacts/web_framework_war_exploded.xml new file mode 100644 index 0000000..0f92b49 --- /dev/null +++ b/.idea/artifacts/web_framework_war_exploded.xml @@ -0,0 +1,35 @@ + + + $PROJECT_DIR$/target/Customer-1.0-SNAPSHOT + + + true + web-framework + war + false + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..774643c --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..63e9001 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..be5f5c6 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_0_0.xml b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_0_0.xml new file mode 100644 index 0000000..b8d3629 --- /dev/null +++ b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_0_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_0_1.xml b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_0_1.xml new file mode 100644 index 0000000..a9d27fe --- /dev/null +++ b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_0_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_0_0.xml b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_0_0.xml new file mode 100644 index 0000000..691d245 --- /dev/null +++ b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_0_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__com_google_protobuf_protobuf_java_3_6_1.xml b/.idea/libraries/Maven__com_google_protobuf_protobuf_java_3_6_1.xml new file mode 100644 index 0000000..4b50daa --- /dev/null +++ b/.idea/libraries/Maven__com_google_protobuf_protobuf_java_3_6_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__commons_dbutils_commons_dbutils_1_7.xml b/.idea/libraries/Maven__commons_dbutils_commons_dbutils_1_7.xml new file mode 100644 index 0000000..24fe1a1 --- /dev/null +++ b/.idea/libraries/Maven__commons_dbutils_commons_dbutils_1_7.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__javax_el_el_api_2_1_2_b05.xml b/.idea/libraries/Maven__javax_el_el_api_2_1_2_b05.xml new file mode 100644 index 0000000..06aa16e --- /dev/null +++ b/.idea/libraries/Maven__javax_el_el_api_2_1_2_b05.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__javax_servlet_javax_servlet_api_4_0_1.xml b/.idea/libraries/Maven__javax_servlet_javax_servlet_api_4_0_1.xml new file mode 100644 index 0000000..b187a30 --- /dev/null +++ b/.idea/libraries/Maven__javax_servlet_javax_servlet_api_4_0_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__javax_servlet_jsp_jsp_api_2_1_3_b06.xml b/.idea/libraries/Maven__javax_servlet_jsp_jsp_api_2_1_3_b06.xml new file mode 100644 index 0000000..c277dac --- /dev/null +++ b/.idea/libraries/Maven__javax_servlet_jsp_jsp_api_2_1_3_b06.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__javax_servlet_jstl_1_2.xml b/.idea/libraries/Maven__javax_servlet_jstl_1_2.xml new file mode 100644 index 0000000..b8b45ac --- /dev/null +++ b/.idea/libraries/Maven__javax_servlet_jstl_1_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__junit_junit_4_12.xml b/.idea/libraries/Maven__junit_junit_4_12.xml new file mode 100644 index 0000000..ef6d875 --- /dev/null +++ b/.idea/libraries/Maven__junit_junit_4_12.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__log4j_log4j_1_2_17.xml b/.idea/libraries/Maven__log4j_log4j_1_2_17.xml new file mode 100644 index 0000000..5a92f60 --- /dev/null +++ b/.idea/libraries/Maven__log4j_log4j_1_2_17.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__mysql_mysql_connector_java_8_0_15.xml b/.idea/libraries/Maven__mysql_mysql_connector_java_8_0_15.xml new file mode 100644 index 0000000..0292e72 --- /dev/null +++ b/.idea/libraries/Maven__mysql_mysql_connector_java_8_0_15.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_glassfish_javax_servlet_3_0_b70.xml b/.idea/libraries/Maven__org_glassfish_javax_servlet_3_0_b70.xml new file mode 100644 index 0000000..0f7f668 --- /dev/null +++ b/.idea/libraries/Maven__org_glassfish_javax_servlet_3_0_b70.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml new file mode 100644 index 0000000..700f2b3 --- /dev/null +++ b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_mybatis_mybatis_3_4_5.xml b/.idea/libraries/Maven__org_mybatis_mybatis_3_4_5.xml new file mode 100644 index 0000000..927c7fb --- /dev/null +++ b/.idea/libraries/Maven__org_mybatis_mybatis_3_4_5.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..5b6a5c4 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..8e99870 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/web-framework.iml b/.idea/web-framework.iml new file mode 100644 index 0000000..a219050 --- /dev/null +++ b/.idea/web-framework.iml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/target/Customer-1.0-SNAPSHOT/META-INF/MANIFEST.MF b/target/Customer-1.0-SNAPSHOT/META-INF/MANIFEST.MF new file mode 100644 index 0000000..254272e --- /dev/null +++ b/target/Customer-1.0-SNAPSHOT/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/target/Customer-1.0-SNAPSHOT/WEB-INF/web.xml b/target/Customer-1.0-SNAPSHOT/WEB-INF/web.xml new file mode 100644 index 0000000..73e9c61 --- /dev/null +++ b/target/Customer-1.0-SNAPSHOT/WEB-INF/web.xml @@ -0,0 +1,8 @@ + + + javaWebendtest + + customer.jsp + index.html + + \ No newline at end of file diff --git a/target/Customer-1.0-SNAPSHOT/customer.jsp b/target/Customer-1.0-SNAPSHOT/customer.jsp new file mode 100644 index 0000000..799bc32 --- /dev/null +++ b/target/Customer-1.0-SNAPSHOT/customer.jsp @@ -0,0 +1,52 @@ +<%@ page language="java" contentType="text/html; charset=utf-8" + pageEncoding="utf-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + + +customer + + + +
+ + + + + + + + + + + + + +<%-- --%> +<%-- --%> +<%-- --%> +<%-- --%> +<%-- --%> +<%-- --%> +<%-- --%> +<%-- --%> + + + +
昵称
账号
密码
确认密码
所属角色--%> +<%-- --%> +<%--
+ +
+
+ + \ No newline at end of file diff --git a/target/Customer-1.0-SNAPSHOT/customerAll.jsp b/target/Customer-1.0-SNAPSHOT/customerAll.jsp new file mode 100644 index 0000000..7a696d7 --- /dev/null +++ b/target/Customer-1.0-SNAPSHOT/customerAll.jsp @@ -0,0 +1,36 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + + + + + 添加 + + + + + + + + + + + + + + + + + + + +
序号昵称账号操作
${obj.id}${obj.loginName}${obj.realName} + 编辑 + 删除 +
+ + \ No newline at end of file diff --git a/target/Customer-1.0-SNAPSHOT/customerEdit.jsp b/target/Customer-1.0-SNAPSHOT/customerEdit.jsp new file mode 100644 index 0000000..582c4b5 --- /dev/null +++ b/target/Customer-1.0-SNAPSHOT/customerEdit.jsp @@ -0,0 +1,30 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + + + + +
+ + + + + + + + + + + + + +
昵称
账号
+
+ + \ No newline at end of file diff --git a/target/Customer-1.0-SNAPSHOT/customerResult.jsp b/target/Customer-1.0-SNAPSHOT/customerResult.jsp new file mode 100644 index 0000000..69118a5 --- /dev/null +++ b/target/Customer-1.0-SNAPSHOT/customerResult.jsp @@ -0,0 +1,17 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + + + + + +添加结果 + + +

${reg}

+ 返回 + + \ No newline at end of file diff --git a/target/Customer-1.0-SNAPSHOT/index.jsp b/target/Customer-1.0-SNAPSHOT/index.jsp new file mode 100644 index 0000000..32a3f4c --- /dev/null +++ b/target/Customer-1.0-SNAPSHOT/index.jsp @@ -0,0 +1,16 @@ +<%-- + Created by IntelliJ IDEA. + User: lsjss + Date: 2021/1/16 + Time: 20:02 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + $Title$ + + + $END$ + + -- Gitee From 5209aee251f9304fdca80c1196331703512f1903 Mon Sep 17 00:00:00 2001 From: 1638894223 <1638894223@qq.com> Date: Thu, 4 Apr 2024 10:48:55 +0800 Subject: [PATCH 3/7] delete .idea --- .../META-INF/MANIFEST.MF | 3 -- target/Customer-1.0-SNAPSHOT/WEB-INF/web.xml | 8 --- target/Customer-1.0-SNAPSHOT/customer.jsp | 52 ------------------- target/Customer-1.0-SNAPSHOT/customerAll.jsp | 36 ------------- target/Customer-1.0-SNAPSHOT/customerEdit.jsp | 30 ----------- .../Customer-1.0-SNAPSHOT/customerResult.jsp | 17 ------ target/Customer-1.0-SNAPSHOT/index.jsp | 16 ------ 7 files changed, 162 deletions(-) delete mode 100644 target/Customer-1.0-SNAPSHOT/META-INF/MANIFEST.MF delete mode 100644 target/Customer-1.0-SNAPSHOT/WEB-INF/web.xml delete mode 100644 target/Customer-1.0-SNAPSHOT/customer.jsp delete mode 100644 target/Customer-1.0-SNAPSHOT/customerAll.jsp delete mode 100644 target/Customer-1.0-SNAPSHOT/customerEdit.jsp delete mode 100644 target/Customer-1.0-SNAPSHOT/customerResult.jsp delete mode 100644 target/Customer-1.0-SNAPSHOT/index.jsp diff --git a/target/Customer-1.0-SNAPSHOT/META-INF/MANIFEST.MF b/target/Customer-1.0-SNAPSHOT/META-INF/MANIFEST.MF deleted file mode 100644 index 254272e..0000000 --- a/target/Customer-1.0-SNAPSHOT/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: - diff --git a/target/Customer-1.0-SNAPSHOT/WEB-INF/web.xml b/target/Customer-1.0-SNAPSHOT/WEB-INF/web.xml deleted file mode 100644 index 73e9c61..0000000 --- a/target/Customer-1.0-SNAPSHOT/WEB-INF/web.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - javaWebendtest - - customer.jsp - index.html - - \ No newline at end of file diff --git a/target/Customer-1.0-SNAPSHOT/customer.jsp b/target/Customer-1.0-SNAPSHOT/customer.jsp deleted file mode 100644 index 799bc32..0000000 --- a/target/Customer-1.0-SNAPSHOT/customer.jsp +++ /dev/null @@ -1,52 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=utf-8" - pageEncoding="utf-8"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> - - - - - -customer - - - -
- - - - - - - - - - - - - -<%-- --%> -<%-- --%> -<%-- --%> -<%-- --%> -<%-- --%> -<%-- --%> -<%-- --%> -<%-- --%> - - - -
昵称
账号
密码
确认密码
所属角色--%> -<%-- --%> -<%--
- -
-
- - \ No newline at end of file diff --git a/target/Customer-1.0-SNAPSHOT/customerAll.jsp b/target/Customer-1.0-SNAPSHOT/customerAll.jsp deleted file mode 100644 index 7a696d7..0000000 --- a/target/Customer-1.0-SNAPSHOT/customerAll.jsp +++ /dev/null @@ -1,36 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> - - - - - - - - 添加 - - - - - - - - - - - - - - - - - - - -
序号昵称账号操作
${obj.id}${obj.loginName}${obj.realName} - 编辑 - 删除 -
- - \ No newline at end of file diff --git a/target/Customer-1.0-SNAPSHOT/customerEdit.jsp b/target/Customer-1.0-SNAPSHOT/customerEdit.jsp deleted file mode 100644 index 582c4b5..0000000 --- a/target/Customer-1.0-SNAPSHOT/customerEdit.jsp +++ /dev/null @@ -1,30 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> - -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> - - - - - - - -
- - - - - - - - - - - - - -
昵称
账号
-
- - \ No newline at end of file diff --git a/target/Customer-1.0-SNAPSHOT/customerResult.jsp b/target/Customer-1.0-SNAPSHOT/customerResult.jsp deleted file mode 100644 index 69118a5..0000000 --- a/target/Customer-1.0-SNAPSHOT/customerResult.jsp +++ /dev/null @@ -1,17 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - - - - - - - -添加结果 - - -

${reg}

- 返回 - - \ No newline at end of file diff --git a/target/Customer-1.0-SNAPSHOT/index.jsp b/target/Customer-1.0-SNAPSHOT/index.jsp deleted file mode 100644 index 32a3f4c..0000000 --- a/target/Customer-1.0-SNAPSHOT/index.jsp +++ /dev/null @@ -1,16 +0,0 @@ -<%-- - Created by IntelliJ IDEA. - User: lsjss - Date: 2021/1/16 - Time: 20:02 - To change this template use File | Settings | File Templates. ---%> -<%@ page contentType="text/html;charset=UTF-8" language="java" %> - - - $Title$ - - - $END$ - - -- Gitee From ef1a1d4b6085e16f0d303ca30d28cb65c9afa14f Mon Sep 17 00:00:00 2001 From: 1638894223 <1638894223@qq.com> Date: Thu, 4 Apr 2024 10:57:12 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/com/dao/T2.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/com/dao/T2.java b/src/test/java/com/dao/T2.java index 8b34790..a5b85d7 100644 --- a/src/test/java/com/dao/T2.java +++ b/src/test/java/com/dao/T2.java @@ -12,6 +12,7 @@ public class T2 { Connection con= JDBC.getConnection(); if(con!=null){ System.out.println("mysql success"); + System.out.println("hello mysql"); }else { System.out.println("mysql err"); } -- Gitee From 068276e9019b232dba46c792e7b0561ff3beb5c1 Mon Sep 17 00:00:00 2001 From: 1638894223 <1638894223@qq.com> Date: Thu, 4 Apr 2024 11:03:01 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BF=AE=E6=94=B92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/com/dao/T2.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/dao/T2.java b/src/test/java/com/dao/T2.java index a5b85d7..4dc455c 100644 --- a/src/test/java/com/dao/T2.java +++ b/src/test/java/com/dao/T2.java @@ -14,7 +14,7 @@ public class T2 { System.out.println("mysql success"); System.out.println("hello mysql"); }else { - System.out.println("mysql err"); + System.out.println("mysql hello"); } } } -- Gitee From 4a4580bd099d9fa62b8e19d768a9c00e95e51509 Mon Sep 17 00:00:00 2001 From: 1638894223 <1638894223@qq.com> Date: Thu, 4 Apr 2024 11:18:34 +0800 Subject: [PATCH 6/7] branch --- src/test/java/com/dao/T2.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/com/dao/T2.java b/src/test/java/com/dao/T2.java index 4dc455c..6912ff0 100644 --- a/src/test/java/com/dao/T2.java +++ b/src/test/java/com/dao/T2.java @@ -13,6 +13,7 @@ public class T2 { if(con!=null){ System.out.println("mysql success"); System.out.println("hello mysql"); + System.out.println("branch!"); }else { System.out.println("mysql hello"); } -- Gitee From 45a670bc518e8ae0127c13059f0f24ad2d3bd2c1 Mon Sep 17 00:00:00 2001 From: 1638894223 <1638894223@qq.com> Date: Thu, 4 Apr 2024 11:03:01 +0800 Subject: [PATCH 7/7] cherry-pick --- src/test/java/com/dao/T2.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/com/dao/T2.java b/src/test/java/com/dao/T2.java index 6912ff0..9033059 100644 --- a/src/test/java/com/dao/T2.java +++ b/src/test/java/com/dao/T2.java @@ -14,6 +14,7 @@ public class T2 { System.out.println("mysql success"); System.out.println("hello mysql"); System.out.println("branch!"); + System.out.println("cherry-pick!"); }else { System.out.println("mysql hello"); } -- Gitee