——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明


基于javaweb的JSP+Servlet简单教师信息管理系统(java+jsp+servlet+mysql+jdbc)
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| <br> <div id="submit"> <tr> <button type="submit" onclick="return checkForm()">添加</button> <button type="reset">重置</button>
</tr> </div> </form>
<script type="text/javascript"> function checkForm() { var id = addForm.id.value; var name = addForm.name.value; var salary = addForm.salary.value;
if (id == "" || id == null) { alert("请输入教职工号"); addForm.id.focus(); return false; } else if (name == "" || name == null) { alert("请输入教师姓名"); addForm.name.focus(); return false; } else if (salary == "" || salary == null) { alert("请输入教工资"); addForm.salary.focus(); return false; } return true; } </script>
<%-- 底部 --%> <jsp:include page="bottom.jsp"/> </body> </html> <%@ page import="com.sjsq.vo.Teacher" %> <%@ page import="com.sjsq.service.TeacherService" %> <%@ page import="com.sjsq.service.impl.TeacherServiceImpl" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>新增教师</title> </head> <body> <% // 设置获取注册时的编码为UTF-8 request.setCharacterEncoding("UTF-8");
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| public void setUsername(String username) { this.username = username; }
public String getPassword() { return password; }
public void setPassword(String password) { this.password = password; }
@Override public String toString() { return "Admin{" + "username='" + username + '\'' + ", password='" + password + '\'' + '}'; } } package com.sjsq.service.impl;
public class AdminServiceImpl implements AdminService{
private AdminDao adminDao = new AdminDaoImpl();
public Admin login(Admin admin) { return adminDao.login(admin); } } package com.sjsq.service;
public interface AdminService {
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| */ public static void close(Connection con, PreparedStatement ps, ResultSet rs) { if (rs != null) { try { rs.close(); } catch (SQLException e) { e.printStackTrace(); } } if (ps != null) { try { ps.close(); } catch (SQLException e) { e.printStackTrace(); } } if (con != null) { try { con.close(); } catch (SQLException e) { e.printStackTrace(); } } }
public static boolean addUpdateDelete(String sql, Object[] arr) { Connection con = null; PreparedStatement ps = null; try { con = DBUtil.getConnection(); ps = con.prepareStatement(sql); if (arr != null && arr.length != 0) { for (int i = 0; i < arr.length; i++) { ps.setObject(i + 1, arr[i]); } } int count = ps.executeUpdate();
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| <div id="submit"> <tr> <button type="submit" onclick="return checkForm()">添加</button> <button type="reset">重置</button>
</tr> </div> </form>
<script type="text/javascript"> function checkForm() { var id = addForm.id.value; var name = addForm.name.value; var salary = addForm.salary.value;
if (id == "" || id == null) { alert("请输入教职工号"); addForm.id.focus(); return false; } else if (name == "" || name == null) { alert("请输入教师姓名"); addForm.name.focus(); return false; } else if (salary == "" || salary == null) { alert("请输入教工资"); addForm.salary.focus(); return false; } return true; } </script>
<%-- 底部 --%> <jsp:include page="bottom.jsp"/> </body> </html> <%@ page import="com.sjsq.vo.Teacher" %> <%@ page import="com.sjsq.service.TeacherService" %> <%@ page import="com.sjsq.service.impl.TeacherServiceImpl" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| * @description: 登录系统实现 */ public class AdminDaoImpl implements AdminDao {
@Override public Admin login(Admin admin) { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = DBUtil.getConnection(); String sql = "select * from admin where username = ? and password = ?"; ps = con.prepareStatement(sql); ps.setObject(1, admin.getUsername()); ps.setObject(2, admin.getPassword()); rs = ps.executeQuery(); Admin adminLogin = null; if (rs.next()) { adminLogin = new Admin(); adminLogin.setUsername(rs.getString("username")); adminLogin.setPassword(rs.getString("password"));
return adminLogin;
} } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace();
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| public String getPassword() { return password; }
public void setPassword(String password) { this.password = password; }
@Override public String toString() { return "Admin{" + "username='" + username + '\'' + ", password='" + password + '\'' + '}'; } } package com.sjsq.service.impl;
public class AdminServiceImpl implements AdminService{
private AdminDao adminDao = new AdminDaoImpl();
public Admin login(Admin admin) { return adminDao.login(admin); } } package com.sjsq.service;
public interface AdminService {
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=342223402507201br
https://javayms.pages.dev?id=342223402507201br