Compare commits

..

No commits in common. "3b555530ab9b35b35aac13c714adeb94054336d1" and "f095cda341fba7d5c8aab1e6def4910849ad48f3" have entirely different histories.

6 changed files with 157 additions and 188 deletions

View File

@ -4,9 +4,7 @@ import cn.edu.cqwu.repair.dao.StuDao;
import cn.edu.cqwu.repair.entity.Stu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttribute;
import javax.servlet.http.HttpServletRequest;
@ -26,74 +24,34 @@ public class StuController {
@Autowired
StuDao stuDao;
@PostMapping("/sturegist.do")
public String Register(String userNo, String username, String password , HttpServletRequest request){
Stu byUsername = stuDao.findByUsername(username);
if(byUsername==null) {
Stu stu = new Stu();
stu.setUserNo(userNo);
stu.setUsername(username);
stu.setPassword(password);
stu.setStatus(0);
String localAddr = request.getLocalAddr();
stu.setRegip(localAddr);
int add = stuDao.add(stu);
if(add==1) {
request.setAttribute("stuRegistMess", "注册成功");
return "redirect:/student/index.jsp";
}
request.setAttribute("stuRegistMess", "注册失败");
return "/student/register";
@RequestMapping("/regist.do")
public String Register(String userNo, String username, String password, String gender, HttpServletRequest request){
Stu stu = new Stu();
stu.setUserNo(userNo);
stu.setUsername(username);
stu.setPassword(password);
stu.setStatus(0);
stu.setGender(gender);
String localAddr = request.getLocalAddr();
stu.setRegip(localAddr);
stuDao.add(stu);
}else{
return "/student/register";
}
return "/student/success";
}
@PostMapping("/stulogin.do")
@RequestMapping("/stulogin.do")
public String login( String username, String password, HttpServletRequest request){
Stu stu = stuDao.validateLogin(username, password);
if(stu!=null) {
request.getSession().setAttribute("stu", stu);
request.setAttribute("stuLoginMess","登陆成功");
return "/student/edit";
}else{
request.setAttribute("stuLoginMess","登陆失败");
request.getSession().setAttribute("student",stu);
return "index";
}
return "/student/success";
}
@RequestMapping("/stueditpassword.do")
public String edit(String password, String oldpassword,HttpServletRequest request, @SessionAttribute Stu stu){
if(oldpassword.equals(stu.getPassword())) {
int i = stuDao.passModify(stu.getUsername(), password);
if(i!=0) {
stu.setPassword(password);
request.getSession().setAttribute("student", stu);
request.setAttribute("stuEditMess","修改成功");
return "/student/edit";
}else{
request.setAttribute("stuEditMess","修改失败");
return "/student/edit";
}
}
request.setAttribute("stuEditMess","修改失败");
return "/student/edit";
}
}

View File

@ -1,4 +1,10 @@
<%--
Created by IntelliJ IDEA.
User: xtaod
Date: 2024/5/12
Time: 下午8:21
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
@ -6,22 +12,19 @@
<%@ page isELIgnored="false" %>
<c:set var="title" value="登录"/>
<c:set var="webroot" value="${pageContext.request.contextPath}"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="${webroot}/styles/bootstrap.min.css">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>${title}</title>
<link rel="stylesheet" href="${webroot}/styles/bootstrap.min.css" crossorigin="anonymous">
<script src="${webroot}/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" href="${webroot}/styles/sidebar.css" crossorigin="anonymous">
<link rel="stylesheet" href="${webroot}/styles/index.css" crossorigin="anonymous"></head>
<link rel="stylesheet" href="${webroot}/styles/index.css" crossorigin="anonymous">
</head>
<body>
<main class="d-flex flex-nowrap">
<%@ include file="includes/header.jsp" %>
<%@ include file="./includes/header.jsp" %>
<main class="form-signin w-100 m-auto">
<div class="toast-container position-fixed bottom-0 end-0 p-3">
@ -37,9 +40,9 @@
</div>
</div>
</div>
<form action="${webroot}/stulogin.do" method="post" >
<form action="${webroot}/login.do" method="post" >
<img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72">
<h1 class="h3 mb-3 fw-normal">登录</h1>
<h1 class="h3 mb-3 fw-normal">请先登录</h1>
<c:if test="${not empty requestScope.stuLoginMess}">
<div class="alert alert-warning" role="alert">
@ -48,11 +51,11 @@
</c:if>
<div class="form-floating">
<input type="text" class="form-control" name="username" id="username" required>
<input type="text" class="form-control" name="username" id="username" value="${username}" required>
<label for="username">用户名</label>
</div>
<div class="form-floating">
<input type="password" class="form-control" name="password" id="password" required>
<input type="password" class="form-control" name="password" id="password" value="${password}" required>
<label for="password">密码</label>
</div>
<div class="input-group mb-3">
@ -64,13 +67,13 @@
</span>
</div>
<button class="btn btn-primary w-100 py-2" type="submit" id="submit">登录</button>
<input class="btn btn-primary w-100 py-2" type="submit" id="submit">
<br/><br/>
</form>
<a href="${webroot}/student/register.jsp">
<a href="${webroot}/register.jsp">
<button class="btn btn-primary w-100 py-2">去注册</button>
</a>
</main>
</main>
</main>
<script src="${webroot}/js/pass.js" type="javascript"></script>
<script>
@ -79,8 +82,5 @@
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLiveExample)
toastBootstrap.show()
</script>
</body>
</html>

View File

@ -1,65 +0,0 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %>
<c:set var="title" value="用户主页"/>
<c:set var="webroot" value="${pageContext.request.contextPath}"/>
<html>
<head>
<link rel="stylesheet" href="${webroot}/styles/bootstrap.min.css">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>${title}</title>
<link rel="stylesheet" href="${webroot}/styles/bootstrap.min.css" crossorigin="anonymous">
<script src="${webroot}/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" href="${webroot}/styles/sidebar.css" crossorigin="anonymous">
<link rel="stylesheet" href="${webroot}/styles/index.css" crossorigin="anonymous"></head>
<body>
<main class="d-flex flex-nowrap">
<%@ include file="../includes/header.jsp" %>
<main class="form-signin w-100 m-auto">
<form action="${webroot}/stueditpassword.do" method="post" >
<img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72">
<h1 class="h3 mb-3 fw-normal">修改用户密码</h1>
<c:if test="${not empty requestScope.stuEditMess}">
<div class="alert alert-warning" role="alert">
${requestScope.stuEditMess}
</div>
</c:if>
<div class="form-floating">
<input type="password" class="form-control" name="oldpassword" id="oldpassword" required>
<label for="oldpassword">旧密码</label>
</div>
<div class="form-floating">
<input type="password" class="form-control" name="password" id="password" required>
<label for="password">新密码</label>
</div>
<button class="btn btn-primary w-100 py-2" type="submit" id="submit">确定</button>
<br/><br/>
</form>
</main>
</main>
<script src="${webroot}/js/pass.js" type="javascript"></script>
<script>
const toastLiveExample = document.getElementById('liveToast')
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLiveExample)
toastBootstrap.show()
</script>
</body>
</html>

View File

@ -1,16 +0,0 @@
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2024/5/12
Time: 21:10
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
</body>
</html>

View File

@ -0,0 +1,84 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %>
<c:set var="title" value="登录"/>
<c:set var="webroot" value="${pageContext.request.contextPath}"/>
<html>
<head>
<link rel="stylesheet" href="${webroot}/styles/bootstrap.min.css">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>${title}</title>
<link rel="stylesheet" href="${webroot}/styles/bootstrap.min.css" crossorigin="anonymous">
<script src="${webroot}/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" href="${webroot}/styles/sidebar.css" crossorigin="anonymous">
<link rel="stylesheet" href="${webroot}/styles/index.css" crossorigin="anonymous"></head>
<body>
<main class="d-flex flex-nowrap">
<%@ include file="../includes/header.jsp" %>
<main class="form-signin w-100 m-auto">
<div class="toast-container position-fixed bottom-0 end-0 p-3">
<div id="liveToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<img src="${webroot}/images/logo.jpg" class="rounded me-2" width="32" height="32">
<strong class="me-auto">提示</strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
1、请牢记您注册时填写的用户名和密码登录本系统时您需要提供正确的用户名和密码</br>
2、忘记用户名或者密码请联系学校管理员
</div>
</div>
</div>
<form action="${webroot}/stulogin.do" method="post" >
<img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72">
<h1 class="h3 mb-3 fw-normal">请先登录</h1>
<c:if test="${not empty requestScope.stuLoginMess}">
<div class="alert alert-warning" role="alert">
${requestScope.stuLoginMess}
</div>
</c:if>
<div class="form-floating">
<input type="text" class="form-control" name="username" id="username" value="${username}" required>
<label for="username">用户名</label>
</div>
<div class="form-floating">
<input type="password" class="form-control" name="password" id="password" value="${password}" required>
<label for="password">密码</label>
</div>
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="验证码" name="code" id="code" required>
<span class="input-group-text">
<img src="${pageContext.request.contextPath}/includes/code.jsp" id="imagecode"
title="点击图片可刷新验证码"
onclick="this.src='${pageContext.request.contextPath}/includes/code.jsp?'+Math.random()">
</span>
</div>
<input class="btn btn-primary w-100 py-2" type="submit" id="submit">
<br/><br/>
</form>
<a href="${webroot}/register.jsp">
<button class="btn btn-primary w-100 py-2">去注册</button>
</a>
</main>
<script src="${webroot}/js/pass.js" type="javascript"></script>
<script>
const toastLiveExample = document.getElementById('liveToast')
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLiveExample)
toastBootstrap.show()
</script>
</body>
</html>

View File

@ -1,12 +1,14 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %>
<c:set var="title" value="注册"/>
<c:set var="title" value="登录"/>
<c:set var="webroot" value="${pageContext.request.contextPath}"/>
<html>
<head>
<title>Title</title>
<link rel="stylesheet" href="${webroot}/styles/bootstrap.min.css">
@ -16,7 +18,7 @@
<link rel="stylesheet" href="${webroot}/styles/bootstrap.min.css" crossorigin="anonymous">
<script src="${webroot}/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" href="${webroot}/styles/sidebar.css" crossorigin="anonymous">
<link rel="stylesheet" href="${webroot}/styles/index.css" crossorigin="anonymous"></head>
<link rel="stylesheet" href="${webroot}/styles/index.css" crossorigin="anonymous">
</head>
<body>
<main class="d-flex flex-nowrap">
@ -36,48 +38,54 @@
</div>
</div>
</div>
<form action="${webroot}/sturegist.do" method="post">
<form action="${webroot}/login.do" method="post" >
<img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72">
<h1 class="h3 mb-3 fw-normal">注册</h1>
<h1 class="h3 mb-3 fw-normal">请先登录</h1>
<c:if test="${not empty requestScope.stuRegistMess}">
<c:if test="${not empty requestScope.stuLoginMess}">
<div class="alert alert-warning" role="alert">
${requestScope.stuRegistMess}
${requestScope.stuLoginMess}
</div>
</c:if>
<div class="form-bottom">
<form role="form" id="myForm" method="post" class="login-form" action="${webroot}/regist.do">
<div class="form-floating">
<label for="userNo">学号</label>
<input type="text" class="form-control" name="userNo" id="userNo" required>
</div>
<div class="form-floating">
<label for="username">用户名</label>
<input type="text" class="form-control" name="username" id="username" required>
</div>
<div class="form-floating">
<label for="password">密码</label>
<div class="form-floating">
<input type="text" class="form-control" name="userNo" id="userNo" required>
<label for="userNo">学号</label>
<input type="password" class="form-control" name="password" id="password" required>
</div>
<div>
<div class="form-floating">
<label for="gender">性别:</label>
<select id="gender" name="gender" required>
<option value="male">男</option>
<option value="female">女</option>
</select>
</div>
</div>
<button class="btn btn-primary w-100 py-2" type="submit" id="submit">注册</button>
</form>
<a href="${webroot}/student/login.jsp">
<button class="btn btn-primary w-100 py-2">去登录</button>
</a>
</div>
<div class="form-floating">
<input type="text" class="form-control" name="username" id="username" required>
<label for="username">用户名</label>
</div>
<div class="form-floating">
<input type="password" class="form-control" name="password" id="password" required>
<label for="password">密码</label>
</div>
<button class="btn btn-primary w-100 py-2" type="submit" id="submit">注册</button>
</form>
<a href="${webroot}/index.jsp">
<button class="btn btn-primary w-100 py-2">去登录</button>
</a>
</main>
</main>
<script src="${webroot}/js/pass.js" type="javascript"></script>