return “error”;
}
//添加成功后,也添加到登录表
Userlogin userlogin = new Userlogin();
userlogin.setUsername(studentCustom.getUserid().toString());
userlogin.setPassword(“123”);
userlogin.setRole(2);
userloginService.save(userlogin);
//重定向
return “redirect:/admin/showStudent”;
}
// 修改学生信息页面显示
@RequestMapping(value = “/editStudent”, method = {RequestMethod.GET})
public String editStudentUI(Integer id, Model model) throws Exception {
if (id == null) {
//加入没有带学生id就进来的话就返回学生显示页面
return “redirect:/admin/showStudent”;
}
StudentCustom studentCustom = studentService.findById(id);
if (studentCustom == null) {
throw new CustomException(“未找到该名学生”);
}
List list = collegeService.finAll();
model.addAttribute(“collegeList”, list);
model.addAttribute(“student”, studentCustom);
return “admin/editStudent”;
}
// 修改学生信息处理
@RequestMapping(value = “/editStudent”, method = {RequestMethod.POST})
public String editStudent(StudentCustom studentCustom) throws Exception {
studentService.updataById(studentCustom.getUserid(), studentCustom);
//重定向
return “redirect:/admin/showStudent”;
}
// 删除学生
@RequestMapping(value = “/removeStudent”, method = {RequestMethod.GET})
private String removeStudent(Integer id) throws Exception {
if (id == null) {
//加入没有带学生id就进来的话就返回学生显示页面
return “admin/showStudent”;
}
studentService.removeById(id);
userloginService.removeByName(id.toString());
return “redirect:/admin/showStudent”;
}
// 搜索学生
@RequestMapping(value = “selectStudent”, method = {RequestMethod.POST})
private String selectStudent(String findByName, Model model) throws Exception {
List list = studentService.findByName(findByName);
model.addAttribute(“studentList”, list);
return “admin/showStudent”;
}
/<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<教师操作>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>/
// 教师页面显示
@RequestMapping(“/showTeacher”)
public String showTeacher(Model model, Integer page) throws Exception {
List list = null;
//页码对象
PagingVO pagingVO = new PagingVO();
//设置总页数
pagingVO.setTotalCount(teacherService.getCountTeacher());
if (page == null || page == 0) {
pagingVO.setToPageNo(1);
list = teacherService.findByPaging(1);
} else {
pagingVO.setToPageNo(page);
list = teacherService.findByPaging(page);
}
model.addAttribute(“teacherList”, list);
model.addAttribute(“pagingVO”, pagingVO);
return “admin/showTeacher”;
}
// 添加教师信息
@RequestMapping(value = “/addTeacher”, method = {RequestMethod.GET})
public String addTeacherUI(Model model) throws Exception {
List list = collegeService.finAll();
model.addAttribute(“collegeList”, list);
return “admin/addTeacher”;
}
// 添加教师信息处理
@RequestMapping(value = “/addTeacher”, method = {RequestMethod.POST})
public String addTeacher(TeacherCustom teacherCustom, Model model) throws Exception {
Boolean result = teacherService.save(teacherCustom);
if (!result) {
model.addAttribute(“message”, “工号重复”);
return “error”;
}
//添加成功后,也添加到登录表
Userlogin userlogin = new Userlogin();
userlogin.setUsername(teacherCustom.getUserid().toString());
userlogin.setPassword(“123”);
userlogin.setRole(1);
userloginService.save(userlogin);
//重定向
return “redirect:/admin/showTeacher”;
}
// 修改教师信息页面显示
@RequestMapping(value = “/editTeacher”, method = {RequestMethod.GET})
public String editTeacherUI(Integer id, Model model) throws Exception {
if (id == null) {
return “redirect:/admin/showTeacher”;
}
TeacherCustom teacherCustom = teacherService.findById(id);
if (teacherCustom == null) {
throw new CustomException(“未找到该名学生”);
}
List list = collegeService.finAll();
model.addAttribute(“collegeList”, list);
model.addAttribute(“teacher”, teacherCustom);
return “admin/editTeacher”;
}
// 修改教师信息页面处理
@RequestMapping(value = “/editTeacher”, method = {RequestMethod.POST})
public String editTeacher(TeacherCustom teacherCustom) throws Exception {
teacherService.updateById(teacherCustom.getUserid(), teacherCustom);
//重定向
return “redirect:/admin/showTeacher”;
}
//删除教师
@RequestMapping(“/removeTeacher”)
public String removeTeacher(Integer id) throws Exception {
if (id == null) {
//加入没有带教师id就进来的话就返回教师显示页面
return “admin/showTeacher”;
}
teacherService.removeById(id);
userloginService.removeByName(id.toString());
return “redirect:/admin/showTeacher”;
}
//搜索教师
@RequestMapping(value = “selectTeacher”, method = {RequestMethod.POST})
private String selectTeacher(String findByName, Model model) throws Exception {
List list = teacherService.findByName(findByName);
model.addAttribute(“teacherList”, list);
return “admin/showTeacher”;
}
/<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<课程操作>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>/
// 课程信息显示
@RequestMapping(“/showCourse”)
public String showCourse(Model model, Integer page) throws Exception {
List list = null;
//页码对象
PagingVO pagingVO = new PagingVO();
//设置总页数
pagingVO.setTotalCount(courseService.getCountCouse());
if (page == null || page == 0) {
pagingVO.setToPageNo(1);
list = courseService.findByPaging(1);
} else {
pagingVO.setToPageNo(page);
list = courseService.findByPaging(page);
}
model.addAttribute(“courseList”, list);
model.addAttribute(“pagingVO”, pagingVO);
return “admin/showCourse”;
}
//添加课程
@RequestMapping(value = “/addCourse”, method = {RequestMethod.GET})
public String addCourseUI(Model model) throws Exception {
List list = teacherService.findAll();
List collegeList = collegeService.finAll();
model.addAttribute(“collegeList”, collegeList);
model.addAttribute(“teacherList”, list);
return “admin/addCourse”;
}
// 添加课程信息处理
@RequestMapping(value = “/addCourse”, method = {RequestMethod.POST})
public String addCourse(CourseCustom courseCustom, Model model) throws Exception {
Boolean result = courseService.save(courseCustom);
if (!result) {
model.addAttribute(“message”, “课程号重复”);
return “error”;
}
//重定向
return “redirect:/admin/showCourse”;
}
// 修改教师信息页面显示
@RequestMapping(value = “/editCourse”, method = {RequestMethod.GET})
public String editCourseUI(Integer id, Model model) throws Exception {
if (id == null) {
return “redirect:/admin/showCourse”;
}
CourseCustom courseCustom = courseService.findById(id);
if (courseCustom == null) {
throw new CustomException(“未找到该课程”);
}
List list = teacherService.findAll();
List collegeList = collegeService.finAll();
model.addAttribute(“teacherList”, list);
model.addAttribute(“collegeList”, collegeList);
model.addAttribute(“course”, courseCustom);
return “admin/editCourse”;
}
// 修改教师信息页面处理
@RequestMapping(value = “/editCourse”, method = {RequestMethod.POST})
public String editCourse(CourseCustom courseCustom) throws Exception {
courseService.upadteById(courseCustom.getCourseid(), courseCustom);
//重定向
return “redirect:/admin/showCourse”;
}
// 删除课程信息
@RequestMapping(“/removeCourse”)
public String removeCourse(Integer id) throws Exception {
if (id == null) {
//加入没有带教师id就进来的话就返回教师显示页面
return “admin/showCourse”;
}
courseService.removeById(id);
return “redirect:/admin/showCourse”;
}
//搜索课程
@RequestMapping(value = “selectCourse”, method = {RequestMethod.POST})
private String selectCourse(String findByName, Model model) throws Exception {
List list = courseService.findByName(findByName);
model.addAttribute(“courseList”, list);
return “admin/showCourse”;
}
/<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<其他操作>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>/
// 普通用户账号密码重置
@RequestMapping(“/userPasswordRest”)
public String userPasswordRestUI() throws Exception {
return “admin/userPasswordRest”;
}
// 普通用户账号密码重置处理
@RequestMapping(value = “/userPasswordRest”, method = {RequestMethod.POST})
public String userPasswordRest(Userlogin userlogin) throws Exception {
Userlogin u = userloginService.findByName(userlogin.getUsername());
if (u != null) {
if (u.getRole() == 0) {
throw new CustomException(“该账户为管理员账户,没法修改”);
}
u.setPassword(userlogin.getPassword());
userloginService.updateByName(userlogin.getUsername(), u);
} else {
throw new CustomException(“没找到该用户”);
}
return “admin/userPasswordRest”;
}
// 本账户密码重置
@RequestMapping(“/passwordRest”)
public String passwordRestUI() throws Exception {
return “admin/passwordRest”;
}
}
LoginController
package com.system.controller;
import com.system.po.Userlogin;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/**
- Created by Jacey on 2017/7/5.
*/
@Controller
public class LoginController {
//登录跳转
@RequestMapping(value = “/login”, method = {RequestMethod.GET})
public String loginUI() throws Exception {
return “…/…/login”;
}
//登录表单处理
@RequestMapping(value = “/login”, method = {RequestMethod.POST})
public String login(Userlogin userlogin) throws Exception {
//Shiro实现登录
UsernamePasswordToken token = new UsernamePasswordToken(userlogin.getUsername(),
userlogin.getPassword());
Subject subject = SecurityUtils.getSubject();
//如果获取不到用户名就是登录失败,但登录失败的话,会直接抛出异常
subject.login(token);
if (subject.hasRole(“admin”)) {
return “redirect:/admin/showStudent”;
} else if (subject.hasRole(“teacher”)) {
return “redirect:/teacher/showCourse”;
} else if (subject.hasRole(“student”)) {
return “redirect:/student/showCourse”;
}
return “/login”;
}
}
RestPasswordController
package com.system.controller;
import com.system.exception.CustomException;
import com.system.po.Userlogin;
import com.system.service.UserloginService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.annotation.Resource;
/**
- Created by Jacey on 2017/7/5.
*/
@Controller
public class RestPasswordController {
@Resource(name = “userloginServiceImpl”)
private UserloginService userloginService;
// 本账户密码重置
@RequestMapping(value = “/passwordRest”, method = {RequestMethod.POST})
public String passwordRest(String oldPassword, String password1) throws Exception {
Subject subject = SecurityUtils.getSubject();
String username = (String) subject.getPrincipal();
Userlogin userlogin = userloginService.findByName(username);
if (!oldPassword.equals(userlogin.getPassword())) {
throw new CustomException(“旧密码不正确”);
} else {
userlogin.setPassword(password1);
userloginService.updateByName(username, userlogin);
}
return “redirect:/logout”;
}
}
StudentController
package com.system.controller;
import com.system.exception.CustomException;
import com.system.po.CourseCustom;
import com.system.po.PagingVO;
import com.system.po.SelectedCourseCustom;
import com.system.po.StudentCustom;
import com.system.service.CourseService;
import com.system.service.SelectedCourseService;
import com.system.service.StudentService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import java.util.List;
/**
- Created by Jacey on 2017/7/5.
*/
@Controller
@RequestMapping(value = “/student”)
public class StudentController {
@Resource(name = “courseServiceImpl”)
private CourseService courseService;
@Resource(name = “studentServiceImpl”)
private StudentService studentService;
@Resource(name = “selectedCourseServiceImpl”)
private SelectedCourseService selectedCourseService;
@RequestMapping(value = “/showCourse”)
public String stuCourseShow(Model model, Integer page) throws Exception {
List list = null;
//页码对象
PagingVO pagingVO = new PagingVO();
//设置总页数
pagingVO.setTotalCount(courseService.getCountCouse());
if (page == null || page == 0) {
pagingVO.setToPageNo(1);
list = courseService.findByPaging(1);
} else {
pagingVO.setToPageNo(page);
list = courseService.findByPaging(page);
}
model.addAttribute(“courseList”, list);
model.addAttribute(“pagingVO”, pagingVO);
return “student/showCourse”;
}
// 选课操作
@RequestMapping(value = “/stuSelectedCourse”)
public String stuSelectedCourse(int id) throws Exception {
//获取当前用户名
Subject subject = SecurityUtils.getSubject();
String username = (String) subject.getPrincipal();
SelectedCourseCustom selectedCourseCustom = new SelectedCourseCustom();
selectedCourseCustom.setCourseid(id);
selectedCourseCustom.setStudentid(Integer.parseInt(username));
SelectedCourseCustom s = selectedCourseService.findOne(selectedCourseCustom);
if (s == null) {
selectedCourseService.save(selectedCourseCustom);
} else {
throw new CustomException(“该门课程你已经选了,不能再选”);
}
return “redirect:/student/selectedCourse”;
}
// 退课操作
@RequestMapping(value = “/outCourse”)
public String outCourse(int id) throws Exception {
Subject subject = SecurityUtils.getSubject();
String username = (String) subject.getPrincipal();
SelectedCourseCustom selectedCourseCustom = new SelectedCourseCustom();
selectedCourseCustom.setCourseid(id);
selectedCourseCustom.setStudentid(Integer.parseInt(username));
selectedCourseService.remove(selectedCourseCustom);
return “redirect:/student/selectedCourse”;
}
// 已选课程
@RequestMapping(value = “/selectedCourse”)
public String selectedCourse(Model model) throws Exception {
//获取当前用户名
Subject subject = SecurityUtils.getSubject();
StudentCustom studentCustom = studentService.findStudentAndSelectCourseListByName((String) subject.getPrincipal());
List list = studentCustom.getSelectedCourseList();
model.addAttribute(“selectedCourseList”, list);
return “student/selectCourse”;
}
// 已修课程
@RequestMapping(value = “/overCourse”)
public String overCourse(Model model) throws Exception {
//获取当前用户名
Subject subject = SecurityUtils.getSubject();
StudentCustom studentCustom = studentService.findStudentAndSelectCourseListByName((String) subject.getPrincipal());
List list = studentCustom.getSelectedCourseList();
model.addAttribute(“selectedCourseList”, list);
return “student/overCourse”;
}
//修改密码
@RequestMapping(value = “/passwordRest”)
public String passwordRest() throws Exception {
return “student/passwordRest”;
}
}
TeacherController
package com.system.controller;
import com.system.po.CourseCustom;
import com.system.po.SelectedCourseCustom;
import com.system.service.CourseService;
import com.system.service.SelectedCourseService;
import com.system.service.TeacherService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.annotation.Resource;
import java.util.List;
/**
- Created by Jacey on 2017/7/6.
*/
@Controller
@RequestMapping(value = “/teacher”)
public class TeacherController {
@Resource(name = “teacherServiceImpl”)
private TeacherService teacherService;
@Resource(name = “courseServiceImpl”)
private CourseService courseService;
@Resource(name = “selectedCourseServiceImpl”)
private SelectedCourseService selectedCourseService;
// 显示我的课程
@RequestMapping(value = “/showCourse”)
public String stuCourseShow(Model model) throws Exception {
Subject subject = SecurityUtils.getSubject();
String username = (String) subject.getPrincipal();
List list = courseService.findByTeacherID(Integer.parseInt(username));
model.addAttribute(“courseList”, list);
return “teacher/showCourse”;
}
// 显示成绩
@RequestMapping(value = “/gradeCourse”, method = {RequestMethod.GET})
public String gradeCourse(Integer id, Model model) throws Exception {
if (id == null) {
return “”;
}
System.out.println(“id:”+id);
List list = selectedCourseService.findByCourseID(id);
model.addAttribute(“selectedCourseList”, list);
return “teacher/showGrade”;
}
// 打分
@RequestMapping(value = “/mark”, method = {RequestMethod.GET})
public String markUI(SelectedCourseCustom scc, Model model) throws Exception {
SelectedCourseCustom selectedCourseCustom = selectedCourseService.findOne(scc);
model.addAttribute(“selectedCourse”, selectedCourseCustom);
return “teacher/mark”;
}
// 打分
@RequestMapping(value = “/mark”, method = {RequestMethod.POST})
public String mark(SelectedCourseCustom scc) throws Exception {
selectedCourseService.updataOne(scc);
return “redirect:/teacher/gradeCourse?id=” + scc.getCourseid();
}
//修改密码
@RequestMapping(value = “/passwordRest”)
public String passwordRest() throws Exception {
return “teacher/passwordRest”;
}
}
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=“http://maven.apache.org/POM/4.0.0” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=“http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>
4.0.0
com.sjsq
Examination
1.0-SNAPSHOT
war
Examination Maven Webapp
http://www.example.com
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
junit
junit
4.12
test
javax.servlet
javax.servlet-api
3.1.0
provided
org.apache.shiro
shiro-core
1.2.3
org.apache.shiro
shiro-web
1.2.3
org.apache.shiro
shiro-spring
1.2.3
org.springframework
spring-context
4.3.8.RELEASE
org.springframework
spring-web
4.3.8.RELEASE
org.springframework
spring-webmvc
4.3.7.RELEASE
org.springframework
spring-tx
4.3.8.RELEASE
org.springframework
spring-aop
4.3.9.RELEASE
org.aspectj
aspectjweaver
1.8.10
org.springframework
spring-jdbc
4.2.5.RELEASE
javax.servlet
jstl
1.2
log4j
log4j
1.2.17
org.mybatis
mybatis
3.4.1
org.mybatis.generator
mybatis-generator-core
1.3.5
org.mybatis
mybatis-spring
1.3.0
org.hibernate
hibernate-validator
5.4.1.Final
com.mchange
c3p0
0.9.5.2
mysql
mysql-connector-java
8.0.13
org.jetbrains
annotations-java5
RELEASE
org.jetbrains
annotations-java5
15.0
2021年Java中高级面试必备知识点总结
在这个部分总结了2019年到目前为止Java常见面试问题,取其面试核心编写成这份文档笔记,从中分析面试官的心理,摸清面试官的“套路”,可以说搞定90%以上的Java中高级面试没一点难度。
本节总结的内容涵盖了:消息队列、Redis缓存、分库分表、读写分离、设计高并发系统、分布式系统、高可用系统、SpringCloud微服务架构等一系列互联网主流高级技术的知识点。
目录:
(上述只是一个整体目录大纲,每个点里面都有如下所示的详细内容,从面试问题——分析面试官心理——剖析面试题——完美解答的一个过程)
部分内容:
对于每一个做技术的来说,学习是不能停止的,小编把2019年到目前为止Java的核心知识提炼出来了,无论你现在是处于什么阶段,如你所见,这份文档的内容无论是对于你找面试工作还是提升技术广度深度都是完美的。
不想被后浪淘汰的话,赶紧搞起来吧,高清完整版一共是888页,需要的话可以点赞+关注
pring整合包–>
org.mybatis
mybatis-spring
1.3.0
org.hibernate
hibernate-validator
5.4.1.Final
com.mchange
c3p0
0.9.5.2
mysql
mysql-connector-java
8.0.13
org.jetbrains
annotations-java5
RELEASE
org.jetbrains
annotations-java5
15.0
2021年Java中高级面试必备知识点总结
在这个部分总结了2019年到目前为止Java常见面试问题,取其面试核心编写成这份文档笔记,从中分析面试官的心理,摸清面试官的“套路”,可以说搞定90%以上的Java中高级面试没一点难度。
本节总结的内容涵盖了:消息队列、Redis缓存、分库分表、读写分离、设计高并发系统、分布式系统、高可用系统、SpringCloud微服务架构等一系列互联网主流高级技术的知识点。
目录:
[外链图片转存中…(img-cHjzJR2F-1714299072971)]
(上述只是一个整体目录大纲,每个点里面都有如下所示的详细内容,从面试问题——分析面试官心理——剖析面试题——完美解答的一个过程)
[外链图片转存中…(img-alm1sdyZ-1714299072971)]
部分内容:
[外链图片转存中…(img-bY7g2XsR-1714299072972)]
[外链图片转存中…(img-ZvahaItr-1714299072972)]
[外链图片转存中…(img-7nqti2Mr-1714299072972)]
对于每一个做技术的来说,学习是不能停止的,小编把2019年到目前为止Java的核心知识提炼出来了,无论你现在是处于什么阶段,如你所见,这份文档的内容无论是对于你找面试工作还是提升技术广度深度都是完美的。
不想被后浪淘汰的话,赶紧搞起来吧,高清完整版一共是888页,需要的话可以点赞+关注