基于javaweb+jsp的学籍管理系统(JavaWeb JSP MySQL Servlet SSM SpringBoot Bootstrap Ajax)
JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript Bootstrap Ajax
基础JSP+Servlet或JSP+SSM(Spring、SpringMVC、MyBatis)框架或JSP+SSM+Maven(pom.xml)框架或SpringBoot…均可
开发工具:eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
public void register(HttpServletResponse response, HttpServletRequest request) throws IOException, ServletException {
String username = Util.decode(request, "username");
String password = Util.decode(request, "password");
System.out.println("username=" + username);
System.out.println("password=" + password);
Map<String, Object> params = new HashMap();
params.put("searchColumn", "username");//使用`username`字段进行模糊查询
params.put("keyword", username);
params.put("startIndex", 0);
params.put("pageSize", Long.MAX_VALUE);
List<User> list = (List<User>) userService.list(params).get("list");
for (User user : list) {
if (user.getUsername().equals(username) /*&& user.getPassword().equals(password)*/) {//说明该用户名已存在,必须换个用户名才能注册
request.getSession().setAttribute("alert_msg", "错误:用户名已存在!");
request.getRequestDispatcher("register.jsp").forward(request, response);
return;
}
}
User vo = new User();
vo.setUsername(username);
vo.setPassword(password);
//vo.setUserType("普通用户");//需要设置一个默认值
userService.insert(vo);
request.getSession().setAttribute("alert_msg", "注册成功!用户名:[" + username + "]");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
<div class="modal-dialog" role="document">
<div class="modal-content">
<form action="noticeAdd" onsubmit="return addCheck()">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myModalLabel">增加公告</h4>
</div>
<div class="modal-body">
<div class="form-group hidden">
<label class="control-label">(hidden)</label>
<input type="text" class="form-control" name="action" value="add">
</div>
<div class="form-group">
<label for="add-noticeName" class="control-label">标题:</label>
<input type="text" class="form-control" name="noticeName" id="add-noticeName">
</div>
<input type="text" class="form-control" name="studentName" id="edit-studentName">
</div>
<div class="form-group">
<label class="control-label">性别:</label>
<input name="studentSex" id="edit-studentSex_男" type="radio" value="男"/>男
<input name="studentSex" id="edit-studentSex_女" type="radio" value="女"/>女
</div>
<div class="form-group">
<label for="edit-studentAge" class="control-label">年龄:</label>
<input type="text" class="form-control" name="studentAge" id="edit-studentAge">
</div>
<div class="form-group">
<label for="edit-studentHometown" class="control-label">籍贯:</label>
<input type="text" class="form-control" name="studentHometown" id="edit-studentHometown">
</div>
<div class="form-group">
<label for="edit-studentPhone" class="control-label">联系方式:</label>
<input type="text" class="form-control" name="studentPhone" id="edit-studentPhone">
<body>
<div class="container">
<div class="loginBox">
<form class="form-horizontal" action="authRegister" method="post" onsubmit="return check()" style="background-color: #ffffffe0;border-radius: 20px;">
<div class="loginLabel"><label style="text-align: center;font-size: 40px;padding-top:40px;font-weight: 700;color:#000000;text-shadow: 2px 3px #FFFFFF;">学籍管理系统</label></div>
<br>
<a href="login.jsp" style="font-size: 24px;color: black;text-decoration: none;padding-left: 140px;">登录</a>       <a href="#" style="font-size: 24px;color:#269abc ;text-decoration: none;">注册</a>
<br>
<br>
<div class="form-group" style="margin-top: 20px;">
<label for="username" class="col-sm-3 control-label">账号</label>
<div class="col-sm-7">
<input type="text" class="form-control" id="username" name="username" placeholder="请输入账号">
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-3 control-label">密码</label>
<div class="col-sm-7">
<input type="password" class="form-control" id="password" name="password" placeholder="请输入密码">
</div>
</div>
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myModalLabel">增加公告</h4>
</div>
<div class="modal-body">
<div class="form-group hidden">
<label class="control-label">(hidden)</label>
<input type="text" class="form-control" name="action" value="add">
</div>
<div class="form-group">
<label for="add-noticeName" class="control-label">标题:</label>
<input type="text" class="form-control" name="noticeName" id="add-noticeName">
</div>
<div class="form-group">
<label for="add-noticeText" class="control-label">内容:</label>
<textarea style="height: 100px;" class="form-control" name="noticeText" id="add-noticeText"></textarea>
</div>
<div class="form-group">
/**
* 根据条件查询公告的列表并跳转回页面
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("noticeList")
public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
this.redirectList(request, response);
}
/**
* 跳转到列表页面
*
* @param request
* @param response
*/
private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
//查询列和关键字
String searchColumn = Util.decode(request, "searchColumn");
String keyword = Util.decode(request, "keyword");
Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
params.put("searchColumn", searchColumn);//要查询的列
params.put("keyword", keyword);//查询的关键字
/**
* 列表页面的显示对象
*
* @param <T>
*/
public class PageBean<T> {
private List<T> list;//根据条件查询出来的list集合
private int totalRecord;//根据条件查询出来的数量
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
this.list = list;
}
public int getTotalRecord() {
return totalRecord;
public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = Util.decode(request, "id");
userService.delete(Arrays.asList(id));
this.redirectList(request, response);
}
/**
* 编辑用户
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("userEdit")
public void edit(HttpServletResponse response, HttpServletRequest request) throws IOException {
</form>
</div>
</div>
</body>
<script type="text/javascript">
//提交之前进行检查,如果return false,则不允许提交
function check() {
//根据ID获取值
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
if (username == "") {
alert("用户名不能为空!");
return false;
}
if (password == "") {
alert("密码不能为空!");
}
}
<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>学籍管理</title>
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/main.css">
<script src="js/jquery-3.5.1.js"></script>
<script src="js/bootstrap.js"></script>
public static String getTime() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis());
}
/**
* 判断字符串是不是中文
*
* @param c
* @return
*/
private static boolean isChinese(char c) {
Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
return (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
|| ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
|| ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
|| ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
|| ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS);
}
运行环境
Java≥6、Tomcat≥7.0、MySQL≥5.5
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
技术框架
JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript Bootstrap Ajax
基础JSP+Servlet或JSP+SSM(Spring、SpringMVC、MyBatis)框架或JSP+SSM+Maven(pom.xml)框架或SpringBoot…均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
登录、注册、退出、用户模块、公告模块、学籍模块的增删改查管理