- Java课设项目实战
===================================================================
本次文章主要是介绍学生成绩管理系统的功能,系统分为三个角色,管理员、教师、学生
=======================================================================
-
开发语言:Java
-
技术:JavaWeb【Servlet】
-
数据库:MySQL
-
架构:B/S
-
源码类型: Web
-
编译工具:Idea、Eclipse、MyEclipse (选其一)
-
其他:jdk1.8、Tomcat8.5 、Navicat
- 登录
- 个人信息
- 课程管理
- 成绩管理
- 教师管理
- 学生管理
- 查询所有账号
- 登录
- 个人信息
- 课程管理
- 成绩管理
- 学生管理
- 登录
- 个人信息【查询登录密码,查询个人信息,修改个人信息】
- 成绩管理
☀️登录☀️
☀️登录☀️
☀️学生总成绩☀️
☀️成绩管理☀️
☀️教师管理☀️
☀️学生管理☀️
☀️用户信息☀️
=========================================================================
代码如下(示例):
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String account = req.getParameter(“account”);
String password = req.getParameter(“password”);
String accounttype = req.getParameter(“accounttype”);
req.getSession().removeAttribute(“message”);
// System.out.println(url);
switch (accounttype){
case “管理员”:
AdminDao adminDao=new IAdminimpl();
List admins = adminDao.getAdmin(account);
if(admins.size()>0){
Admin admin = admins.get(0);
if(admin.getPassword().equals(password)){
req.getSession().setAttribute(“admin”,admin);
resp.sendRedirect(“admin/index.jsp”);
}
}
break;
case “医生”:
DoctorDao doctorDao=new DoctorDao();
String where=“where account =?”;
List doctors = doctorDao.query(where, new Object[]{account});
if(doctors.size()>0){
Doctor doctor = doctors.get(0);
if(doctor.getPassword().equals(password)){
req.getSession().setAttribute(“doctor”,doctor);
resp.sendRedirect(“doctor”);
return;
}
}
req.getSession().setAttribute(“message”,“用户名或密码错误!!”);
req.getRequestDispatcher(“doctor/login.jsp”).forward(req,resp);
break;
case “患者”:
PatientDao patientDao=new PatientDao();
List patients = patientDao.query(“account”,account);
if(patients.size()>0){
Patient patient = patients.get(0);
if(patient.getPassword().equals(password)){
req.getSession().setAttribute(“patient”,patient);
String url= (String) req.getSession().getAttribute(“url”);
if(url==null)
url=“index.jsp”;
resp.sendRedirect(url);
return;
}
}
req.getSession().setAttribute(“message”,“用户名或密码错误!!”);
resp.sendRedirect(“login.jsp”);
break;
}
}
代码如下(示例):
public static boolean sendMail(String to, String content){
Properties prop = new Properties();
prop.setProperty(“mail.host”, host);
prop.setProperty(“mail.smtp.auth”, “true”);
prop.setProperty(“mail.transport.protocol”, “smtp”);
/* prop.put(“mail.smtp.ssl.enable”, true);*/
// 开启SSL加密,否则会失败
try {
MailSSLSocketFactory sf = new MailSSLSocketFactory();
sf.setTrustAllHosts(true);
prop.put(“mail.smtp.ssl.enable”, “true”);
prop.put(“mail.smtp.ssl.socketFactory”, sf);
Session session = Session.getInstance(prop);
/* prop.put(“mail.smtp.ssl.enable”, true);*/
Transport ts = session.getTransport();
// 连接邮件服务器:邮箱类型,帐号,授权码代替密码(更安全)
ts.connect(host,from, password);//后面的字符是授权码 // 创建邮件对象
MimeMessage message = new MimeMessage(session);
// 指明邮件的发件人
message.setFrom(new InternetAddress(from));