student登录注册

This commit is contained in:
wobeitaoleshigexuruo 2024-05-12 20:32:38 +08:00
parent 217dd9f137
commit 695a85d7da
6 changed files with 268 additions and 0 deletions

View File

@ -7,6 +7,7 @@
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
<option name="workspaceImportForciblyTurnedOn" value="true" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />

10
.idea/webContexts.xml Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="WebContextManager">
<option name="state">
<map>
<entry key="file://$PROJECT_DIR$/src/main/webapp/student/register.jsp" value="file://$PROJECT_DIR$/src/main/webapp/student" />
</map>
</option>
</component>
</project>

View File

@ -0,0 +1,57 @@
package cn.edu.cqwu.repair.controller;
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.RequestMapping;
import javax.servlet.http.HttpServletRequest;
@Controller
public class StuController {
//
// @Resource
// private StudentService studentService;
//
// @Resource
// private RepairService repairService;
//
// @Resource
// private UrgentRepairService urgentRepairService;
@Autowired
StuDao stuDao;
@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);
return "/student/success";
}
@RequestMapping("/stulogin.do")
public String login( String username, String password, HttpServletRequest request){
Stu stu = stuDao.validateLogin(username, password);
request.getSession().setAttribute("student",stu);
return "/student/success";
}
}

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

@ -0,0 +1,100 @@
<%@ 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>
<title>Title</title>
<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}/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>
<c:if test="${not empty requestScope.stuLoginMess}">
<div class="alert alert-warning" role="alert">
${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>
<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>
</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

@ -0,0 +1,16 @@
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2024/5/12
Time: 20:03
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>
<h1>成功</h1>
</body>
</html>