package com.xhu.controller;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.xhu.entity.SelectInfor;
import com.xhu.entity.User;
import com.xhu.serviceImp.LoginServiceImp;
import com.xhu.util.SendEmail;
@Controller
@RequestMapping("/login")
public class Login {
private static String changeStatus="nullInfor";
@Autowired
private LoginServiceImp loginService;
@RequestMapping("/index")
public String login(){
return "login";
}
@RequestMapping("doLogin")
@ResponseBody
//public String doLogin(@RequestParam("username") String username,@RequestParam("password") String password,@RequestParam("code") String code,@RequestParam("role") String role){
public String doLpgin(HttpServletRequest http){
HttpSession session = http.getSession();
String getCode = (String) session.getAttribute("randCheckCode");
String code = http.getParameter("code").trim();
String username = http.getParameter("username").trim();
String password = http.getParameter("password").trim();
String role = http.getParameter("role").trim();
if(username==null||username==""||password==null||password==""){
return "wrong";
}
if(!getCode.trim().equalsIgnoreCase(code)){
return "wrongCode";
}
User user = loginService.selectByUsername(username);
if(user==null){
return "wrong";
}
session.setAttribute("username", user.getUsername());
if(!user.getPassword().equals(password)){
return "wrong";
}
System.out.println(user.getRole());
if(user.getRole().equals("admin")){
return "admin";
}else{
if(user.getRole().equals(role)){
return role;
}else if(!user.getRole().equals(role)){
return "wrong";
}
}
return "success";
}
@RequestMapping("/doregist")
@ResponseBody
public String doRegist(HttpServletRequest http){
String username = http.getParameter("username");
String cnUser = http.getParameter("cnUser");
String email = http.getParameter("email");
String password = http.getParameter("password");
int clazz = Integer.parseInt(http.getParameter("clazz"));
int department = Integer.parseInt(http.getParameter("department"));
int num = loginService.insertUser(username, password, cnUser,email, clazz, department,"student");
if(num>0){
return "success";
}
else if(num==0){
return "fail";
}
else{
return "doAgin";
}
}
@RequestMapping("/getInfor1")
@ResponseBody
public List<SelectInfor> getInfor1(){
List<SelectInfor> list = loginService.getClazzInfor();
return list;
}
@RequestMapping("/getInfor2")
@ResponseBody
public List<SelectInfor> getInfor2(){
List<SelectInfor> list = loginService.getDepartmentInfor();
return list;
}
@RequestMapping("/doChange")
@ResponseBody
public String doChange(HttpServletRequest http,@RequestParam("changeUser") String username,@RequestParam("changeCode")String code){
HttpSession session = http.getSession();
String getCode = (String) session.getAttribute("randCheckCode");
if(!getCode.equalsIgnoreCase(code)){
return "wrongCode";
}
User user = loginService.selectByUsername(username);
if(user==null){
return "noUser";
}else{
return "success";
}
}
@RequestMapping("/sendMessage")
@ResponseBody
public List<String> sendMessage(@Param("username") String username) {
String randomCode = Math.random() + "";
//查询邮箱
String email = loginService.selectByUsername(username).getEmail();
// System.out.println(email);
loginService.updateCode(randomCode, username);
// System.out.println(changeStatus);
// System.out.println("---------------");
//sengEmail(email, username, randomCode);
// System.out.println("1--------->"+changeStatus);
SendEmail se = new SendEmail(email, username, randomCode);
// se.start(); //配合SendEmail类中线程sleep,笨方法
// try {
// se.join(); //加入。 一个线程如果执行join语句,那么就有新的线程加入,执行该语句的线程必须要让步给新加入的线程先完成任务,然后才能继续执行。
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
se.start();
// System.out.println(se.isAlive() ); //测试数据
// try {
// se.wait();
// } catch (InterruptedException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// }
// System.out.println(se.isAlive() );
synchronized(Thread.currentThread()){
try {
Thread.currentThread().setName(("sendEmailThread"));
// System.out.println(Thread.currentThread());
Thread.currentThread().wait(600000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
// System.out.println("2--------->"+changeStatus);
List<String> list = new ArrayList();
list.add(changeStatus);
list.add(username);
changeStatus="nullInfor";
return list;
}
@RequestMapping("/validate")
@ResponseBody
public String validate(@Param("username") String username, @Param("randomCode") String randomCode) {
User user = loginService.selectByUsername(username);
if (user != null) {
if (user.getRandCode().equals(randomCode)) {
changeStatus = "success";
Thread thread = new Thread();
// System.out.println(thread.getName());
for (Thread t : Thread.getAllStackTraces().keySet()) { //获取线程池中所有的线程,并找到sendEmailThread线程
if (t.getName().equals("sendEmailThread"))
thread = t;
}
// System.out.println(thread.getName());
synchronized (thread) {
thread.notify();
}
return "验证成功,请回到页面进行修改";
} else {
changeStatus = "errorCode";
return "验证码错误";
}
} else {
changeStatus = "errorUser";
return "用户错误";
}
}
@RequestMapping("/updatePass")
@ResponseBody
public String updatePass(@RequestParam("newPass")String newPass,@RequestParam("getUserInfor2") String getUserInfor2){
if(loginService.updatePassword(getUserInfor2, newPass)!=0)
return "yes";
else
return "no";
}
// 閭欢鍙戦�佺▼搴�
// private void sengEmail(String email, String username, String randomCode) {
// System.out.println("111");
// // 鏀朵欢浜虹數瀛愰偖绠�
// String to = email;
//
// // 鍙戜欢浜虹數瀛愰偖绠�
// String from = "a823990448@163.com";// hellojulang@163.com
//
// // 鎸囧畾鍙戦�侀偖浠剁殑涓绘満涓�
// String host = "smtp.163.com";
//
// // 鑾峰彇绯荤粺灞炴��
// Properties properties = System.getProperties();
//
// // 璁剧疆閭欢鏈嶅姟鍣�
// properties.setProperty("mail.smtp.host", host);
//
// properties.put("mail.smtp.auth", "true");
// // 鑾峰彇榛樿session瀵硅薄
// Session session = Session.getDefaultInstance(properties, new Authenticator() {
// public PasswordAuthentication getPasswordAuthentication() {
// return new PasswordAuthentication("a823990448@163.com", "zlf123456"); // 鍙戜欢浜洪偖浠剁敤鎴峰悕銆佸瘑鐮�
// }
// });
//
// try {
// // 鍒涘缓榛樿鐨� MimeMessage 瀵硅薄
// MimeMessage message = new MimeMessage(session);
//
// // Set From: 澶撮儴澶村瓧娈�
// message.setFrom(new InternetAddress(from));
//
// // Set To: 澶撮儴澶村瓧娈�
// message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
//
没有合适的资源?快使用搜索试试~ 我知道了~
基于SSM开发的在线考试系统源码+sql数据库(毕设项目).zip
共656个文件
css:202个
png:153个
class:77个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 2 下载量 48 浏览量
2023-06-08
18:14:55
上传
评论
收藏 18.05MB ZIP 举报
温馨提示
JSP基于SSM在线考试系统毕业源码案例设计+sql数据库(毕设项目) ## 运行环境:jdk8 + tomcat8 + mysql + Eclipse/Idea ## 项目技术: spring+spring mvc+mybatis+jquery+esayui+jsp 系统一共3个身份:学生,老师和管理员。管理员登录后可以发布公告信息,管理所有用户信息,不同的角色分配不同的权限;老师登录系统后可以管理题库题目信息,生成试卷信息然后给试卷分配考试时间,其中题目类型有单选,多选,判断,问答题;学生登录后可以进行考试,提交考试答案后老师可以批改学生的答案,学生可以查询自己的考试成绩! 学生账号: student_1 密码:123 老师账号: teacher 密码:123 管理员账号:admin_1 密码:123 【备注】 该项目代码主要针对计算机、自动化等相关专业的学生从业者下载使用,项目代码都经过严格调试,确保可以运行!放心下载使用。 也可作为期末课程设计、课程大作业、毕业设计等。具有较高的学习借鉴价值!也可直接当做个人项目使用。
资源推荐
资源详情
资源评论
收起资源包目录
基于SSM开发的在线考试系统源码+sql数据库(毕设项目).zip (656个子文件)
ExamController.class 7KB
Login.class 7KB
PictureCheckCode.class 5KB
Main.class 5KB
Student.class 5KB
ExamMaController.class 4KB
StuManageController.class 4KB
Texam.class 4KB
Question.class 4KB
LoginServiceImp.class 4KB
PaperServiceImpl.class 4KB
ExamServiceImp.class 3KB
TexamServiceImp.class 3KB
ShowTreeServiceImp.class 3KB
PermissionController.class 3KB
DoLoginHandlerInterceptor.class 3KB
QuestionController.class 3KB
SendEmail.class 3KB
QuestionServiceImp.class 3KB
PaperController.class 3KB
Permission.class 3KB
Node.class 3KB
Teacher.class 2KB
ScoreController.class 2KB
ShowStuServcieImp.class 2KB
Shortanswer.class 2KB
User.class 2KB
Clazz.class 2KB
ExamInfor.class 2KB
Department.class 2KB
StudentServiceImp.class 2KB
News.class 2KB
GetNewsServiceImp.class 1KB
QuestionPaper.class 1KB
Paper.class 1KB
Tree.class 1KB
TexamMapper.class 1KB
LoginDao.class 1KB
TreeServiceImp.class 1KB
ExamInforSeriveImp.class 1KB
InsertException.class 1KB
SelectInfor.class 1KB
DistributePermMapper.class 935B
PaperMapper.class 913B
QuestionType.class 860B
InsertMsgServiceImp.class 835B
Difficulty.class 815B
ShortanswerMapper.class 810B
UpdateInforServiceImp.class 805B
QuestionMapper.class 801B
QuestionPaperMapper.class 797B
StudentMapper.class 760B
SendEmail$1.class 753B
ExamService.class 698B
TeaxmService.class 683B
PaperService.class 678B
Page.class 648B
ShowStuMapper.class 580B
ShowTreeService.class 574B
UserMapper.class 569B
LoginService.class 552B
TeacherMapper.class 540B
QuestionService.class 472B
QuestionTypeMapper.class 410B
DifficultyMapper.class 402B
ExamDao.class 399B
ShowStuService.class 398B
PermissionMapper.class 392B
InsertInforDao.class 350B
StudentService.class 349B
NewsInforDao.class 314B
ExamInforService.class 308B
GetNewsService.class 294B
TreeService.class 264B
InsertMsgService.class 209B
UpdateInforService.class 182B
UpdateInforDao.class 170B
.classpath 889B
org.eclipse.wst.common.component 580B
org.eclipse.wst.jsdt.ui.superType.container 49B
easyui.css 66KB
easyui.css 65KB
easyui.css 65KB
easyui.css 65KB
easyui.css 63KB
easyui.css 62KB
tabs.css 9KB
tabs.css 9KB
tabs.css 9KB
tabs.css 9KB
tabs.css 7KB
tabs.css 7KB
mobile.css 7KB
color.css 6KB
datagrid.css 6KB
datagrid.css 6KB
datagrid.css 6KB
panel.css 6KB
panel.css 6KB
panel.css 6KB
共 656 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
- Uchiha小陈2024-02-09资源简直太好了,完美解决了当下遇到的难题,这样的资源很难不支持~
- LIJIAN123882024-01-18总算找到了想要的资源,搞定遇到的大问题,赞赞赞!
z同学的编程之路
- 粉丝: 1805
- 资源: 2129
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功