Compare commits

...

No commits in common. 'main' and 'master' have entirely different histories.
main ... master

@ -1,44 +0,0 @@
<html>
<head>
<title>HTML快速入门</title>
<!-- 给页面加个基础样式,让它更好看 -->
<style>
body {
font-family: 微软雅黑;
text-align: center;
margin-top: 50px;
background-color: #f0f0f0;
}
h1 {
color: #2c3e50;
}
/* 按钮样式 */
.btn {
padding: 10px 20px;
font-size: 18px;
background-color: #3498db;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
margin-top: 20px;
}
.btn:hover {
background-color: #2980b9;
}
</style>
</head>
<body>
<h1>Hello HTML</h1>
< img src="img/1.png" alt="示例图片">
<!-- 新增按钮,点击触发弹窗 -->
<button class="btn" onclick="showMsg()">点击我!</button>
<!-- 新增JS交互代码 -->
<script>
function showMsg() {
alert("🎉 欢迎使用Git版本控制\n这是你扩展的第一个HTML交互功能~");
}
</script>
</body>
</html>

@ -1,2 +0,0 @@
# yyds

@ -0,0 +1,67 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>登录</title>
</head>
<body>
<h2>用户登录</h2>
<form method="post" action="login.jsp">
<div>
用户名:<input type="text" name="name" required>
</div>
<div>
密码:<input type="password" name="password" required>
</div>
<div>
<button type="submit">登录</button>
</div>
</form>
<%
if ("POST".equalsIgnoreCase(request.getMethod())) {
String name = request.getParameter("name");
String password = request.getParameter("password");
String url = "jdbc:mysql://localhost:3306/demo?useSSL=false&serverTimezone=UTC&characterEncoding=utf8";
String dbUser = "root";
String dbPwd = "1234";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
Class.forName("com.mysql.cj.jdbc.Driver");
conn = DriverManager.getConnection(url, dbUser, dbPwd);
String sql = "SELECT * FROM tb_user WHERE name = ? AND password = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, name);
pstmt.setString(2, password);
rs = pstmt.executeQuery();
if (rs.next()) {
out.println("<p>用户存在</p >");
} else {
out.println("<p>用户不存在</p >");
}
} catch (ClassNotFoundException e) {
out.println("<p>数据库驱动加载失败!</p >");
} catch (SQLException e) {
out.println("<p>数据库操作失败:" + e.getMessage() + "</p >");
} finally {
try {
if (rs != null) rs.close();
if (pstmt != null) pstmt.close();
if (conn != null) conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
%>
</body>
</html>

@ -0,0 +1,16 @@
# JDBC 登录演示项目
基于 JDBC 的用户登录验证 Demo
## 功能
- 实现用户账号密码的数据库校验
- 练习 JSP + Servlet + MySQL 开发流程
## 技术栈
- Java
- JSP/Servlet
- MySQL 8.0
- Tomcat 7
## 作者
zhangsiyi
2026-03-27
Loading…
Cancel
Save