基于javaweb+mysql的jsp+servlet高校教学评价管理系统(java+jsp+javascript+servlet+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的JSP+Servlet高校教学评价管理系统(java+jsp+javascript+servlet+mysql)
项目介绍
本项目为后台管理系统,分为管理员与学生两种角色;
管理员角色包含以下功能:
管理员登录,管理员管理,修改密码,教师管理,学生管理,评价指标管理,评价结果查看等功能。
学生角色包含以下功能: 学生角色登录,个人信息修改,评价某一个老师等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目:否;
技术栈
JSP+CSS+JavaScript+servlet+mysql
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中dao/DB.java配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入http://localhost:8080/pingjia 登录 管理员账号/密码:admin/admin 用户账号/密码: liuguangliang/000000
liuService.save_pingjia(pingjia_id, tea_id, zongfenshu,shijian,stu_id);
req.setAttribute("msg", "评价完毕");
}
String targetURL = "/common/msg.jsp";
dispatch(targetURL, req, res);
}
public void pingjiaMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
List pingjiaList=new ArrayList();
String sql="select * from t_pingjia order by tea_id";
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
Tpingjia pingjia=new Tpingjia();
pingjia.setId(rs.getString("id"));
pingjia.setTea_id(rs.getInt("tea_id"));
pingjia.setZongfenshu(rs.getInt("zongfenshu"));
pingjia.setShijian(rs.getString("shijian"));
pingjia.setStu_id(rs.getInt("stu_id"));
pingjia.setTea(liuService.getTea(rs.getInt("tea_id")));
pingjia.setStu(liuService.getStu(rs.getInt("stu_id")));
pingjiaList.add(pingjia);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("pingjiaList", pingjiaList);
req.getRequestDispatcher("admin/pingjia/pingjiaMana.jsp").forward(req, res);
}
ResultSet rs=mydb.getRs();
while(rs.next())
{
Tstu stu=new Tstu();
stu.setId(rs.getInt("id"));
stu.setXuehao(rs.getString("xuehao"));
stu.setName1(rs.getString("name1"));
stu.setSex(rs.getString("sex"));
stu.setAge(rs.getInt("age"));
stu.setLoginname(rs.getString("loginname"));
stu.setLoginpw(rs.getString("loginpw"));
stuList.add(stu);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("stuList", stuList);
req.getRequestDispatcher("admin/stu/stuMana.jsp").forward(req, res);
}
public void stuEdit_stu(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String xuehao=req.getParameter("xuehao");
String name1=req.getParameter("name1");
String sex=req.getParameter("sex");
int age=Integer.parseInt(req.getParameter("age"));
String loginname=req.getParameter("loginname");
String loginpw=req.getParameter("loginpw");
String sql="update t_stu set xuehao=?,name1=?,sex=?,age=?,loginname=?,loginpw=? where id="+Integer.parseInt(req.getParameter("id"));
Object[] params={xuehao,name1,sex,age,loginname,loginpw};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("msg", "修改成功。重新登录后生效");
String targetURL = "/common/msg.jsp";
dispatch(targetURL, req, res);
}
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
{
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
{
req.setAttribute("msg", "评价完毕");
}
String targetURL = "/common/msg.jsp";
dispatch(targetURL, req, res);
}
public void pingjiaMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
List pingjiaList=new ArrayList();
String sql="select * from t_pingjia order by tea_id";
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
Tpingjia pingjia=new Tpingjia();
pingjia.setId(rs.getString("id"));
pingjia.setTea_id(rs.getInt("tea_id"));
pingjia.setZongfenshu(rs.getInt("zongfenshu"));
pingjia.setShijian(rs.getString("shijian"));
pingjia.setStu_id(rs.getInt("stu_id"));
pingjia.setTea(liuService.getTea(rs.getInt("tea_id")));
pingjia.setStu(liuService.getStu(rs.getInt("stu_id")));
pingjiaList.add(pingjia);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("pingjiaList", pingjiaList);
req.getRequestDispatcher("admin/pingjia/pingjiaMana.jsp").forward(req, res);
}
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
{
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
{
public class tea_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
if(type.endsWith("teaMana"))
{
teaMana(req, res);
}
if(type.endsWith("teaAdd"))
{
teaAdd(req, res);
}
if(type.endsWith("teaDel"))
{
teaDel(req, res);
}
if(type.endsWith("teaAll"))
{
teaAll(req, res);
}
}
public void teaAdd(HttpServletRequest req,HttpServletResponse res)
{
String bianhao=req.getParameter("bianhao");
String name=req.getParameter("name");
String sex=req.getParameter("sex");
int age=Integer.parseInt(req.getParameter("age"));
String del="no";
String sql="insert into t_tea(bianhao,name,sex,age,del) values(?,?,?,?,?)";
Object[] params={bianhao,name,sex,age,del};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "tea?type=teaMana");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void teaDel(HttpServletRequest req,HttpServletResponse res)
{
String sql="update t_tea set del='yes' where id="+Integer.parseInt(req.getParameter("id"));
Object[] params={};
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
{
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
{
dispatch.forward(request, response);
return;
}
catch (ServletException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void destroy()
{
}
}
if(type.endsWith("adminMana"))
{
adminMana(req, res);
}
if(type.endsWith("adminAdd"))
{
adminAdd(req, res);
}
if(type.endsWith("adminDel"))
{
adminDel(req, res);
}
}
public void adminMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
List adminList=new ArrayList();
String sql="select * from t_admin";
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
TAdmin admin=new TAdmin();
admin.setUserId(rs.getInt("userId"));
admin.setUserName(rs.getString("userName"));
admin.setUserPw(rs.getString("userPw"));
adminList.add(admin);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("adminList", adminList);
req.getRequestDispatcher("admin/admin/adminMana.jsp").forward(req, res);
}
public void adminAdd(HttpServletRequest req,HttpServletResponse res)
{
String userName=req.getParameter("userName");
e.printStackTrace();
}
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void destroy()
{
}
}
public class loginService {
public static int currentStudentId = 0;
public String login(String userName, String userPw, int userType) {
System.out.println("userType" + userType);
try {
Thread.sleep(700);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String result = "no";
if (userType == 0)//系统管理员登陆
}
if(type.endsWith("stuEdit_stu"))
{
stuEdit_stu(req, res);
}
}
public void stuAdd(HttpServletRequest req,HttpServletResponse res)
{
String xuehao=req.getParameter("xuehao");
String name1=req.getParameter("name1");
String sex=req.getParameter("sex");
int age=Integer.parseInt(req.getParameter("age"));
String loginname=req.getParameter("loginname");
String loginpw=req.getParameter("loginpw");
String del="no";
String sql="insert into t_stu(xuehao,name1,sex,age,loginname,loginpw,del) values(?,?,?,?,?,?,?)";
Object[] params={xuehao,name1,sex,age,loginname,loginpw,del};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "stu?type=stuMana");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void stuDel(HttpServletRequest req,HttpServletResponse res)
{
String sql="update t_stu set del='yes' where id="+Integer.parseInt(req.getParameter("id"));
Object[] params={};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "stu?type=stuMana");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void stuMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
DB mydb = new DB();
mydb.doPstm(sql, params);
try {
ResultSet rs = mydb.getRs();
boolean mark = (rs == null || !rs.next() ? false : true);
if (mark == false) {
result = "no";
} else {
result = "yes";
TAdmin admin = new TAdmin();
admin.setUserId(rs.getInt("userId"));
admin.setUserName(rs.getString("userName"));
admin.setUserPw(rs.getString("userPw"));
session.setAttribute("userType", 0);
session.setAttribute("admin", admin);
}
rs.close();
} catch (SQLException e) {
System.out.println("登录失败!");
e.printStackTrace();
} finally {
mydb.closed();
}
}
if (userType == 1) {
}
if (userType == 2) {
WebContext ctx = WebContextFactory.get();
HttpSession session = ctx.getSession();
String sql = "select * from t_stu where del='no' and loginname=? and loginpw=?";
Object[] params = {userName, userPw};
DB mydb = new DB();
mydb.doPstm(sql, params);
try {
ResultSet rs = mydb.getRs();
boolean mark = (rs == null || !rs.next() ? false : true);
if (mark == false) {
result = "no";
} else {
public void teaDel(HttpServletRequest req,HttpServletResponse res)
{
String sql="update t_tea set del='yes' where id="+Integer.parseInt(req.getParameter("id"));
Object[] params={};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "tea?type=teaMana");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void teaMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
List teaList=new ArrayList();
String sql="select * from t_tea where del='no'";
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
Ttea tea=new Ttea();
tea.setId(rs.getInt("id"));
tea.setBianhao(rs.getString("bianhao"));
tea.setName(rs.getString("name"));
tea.setSex(rs.getString("sex"));
tea.setAge(rs.getInt("age"));
teaList.add(tea);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.getRequestDispatcher("astu/zhibiao/zhibiaoAll.jsp").forward(req, res);
}
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
{
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
{
dispatch.forward(request, response);
return;
}
catch (ServletException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void destroy()
{
}
}
}
public class tea_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
if(type.endsWith("teaMana"))
{
teaMana(req, res);
}
if(type.endsWith("teaAdd"))
{
teaAdd(req, res);
}
if(type.endsWith("teaDel"))
{
teaDel(req, res);
}
if(type.endsWith("teaAll"))
{
stu.setXuehao(rs.getString("xuehao"));
stu.setName1(rs.getString("name1"));
stu.setSex(rs.getString("sex"));
stu.setAge(rs.getInt("age"));
stu.setLoginname(rs.getString("loginname"));
stu.setLoginpw(rs.getString("loginpw"));
System.out.println(stu.getAge() + "%%%");
session.setAttribute("userType", 2);
session.setAttribute("stu", stu);
loginService.currentStudentId = stu.getId();
}
rs.close();
} catch (SQLException e) {
System.out.println("登录失败!");
e.printStackTrace();
} finally {
mydb.closed();
}
}
return result;
}
public String adminPwEdit(String userPwNew) {
System.out.println("DDDD");
try {
Thread.sleep(700);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
WebContext ctx = WebContextFactory.get();
HttpSession session = ctx.getSession();
TAdmin admin = (TAdmin) session.getAttribute("admin");
String sql = "update t_admin set userPw=? where userId=?";
Object[] params = {userPwNew, admin.getUserId()};
DB mydb = new DB();
mydb.doPstm(sql, params);
return "yes";
req.getRequestDispatcher("astu/zhibiao/zhibiaoAll.jsp").forward(req, res);
}
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
{
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
{
dispatch.forward(request, response);
return;
}
catch (ServletException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void destroy()
{
}
}
{
String userName=req.getParameter("userName");
String userPw=req.getParameter("userPw");
String sql="insert into t_admin(userName,userPw) values(?,?)";
Object[] params={userName,userPw};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "admin?type=adminMana");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void adminDel(HttpServletRequest req,HttpServletResponse res)
{
String sql="delete from t_admin where userId="+Integer.parseInt(req.getParameter("userId"));
Object[] params={};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "admin?type=adminMana");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
{
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
{
dispatch.forward(request, response);
return;
}
catch (ServletException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public class tea_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
if(type.endsWith("teaMana"))
{
teaMana(req, res);
}
if(type.endsWith("teaAdd"))
{
teaAdd(req, res);
}
if(type.endsWith("teaDel"))
{
teaDel(req, res);
}
if(type.endsWith("teaAll"))
{
teaAll(req, res);
}
}
public void teaAdd(HttpServletRequest req,HttpServletResponse res)
{
String bianhao=req.getParameter("bianhao");
String name=req.getParameter("name");
String sex=req.getParameter("sex");
int age=Integer.parseInt(req.getParameter("age"));
String del="no";
String sql="insert into t_tea(bianhao,name,sex,age,del) values(?,?,?,?,?)";
Object[] params={bianhao,name,sex,age,del};
DB mydb=new DB();
public void teaAdd(HttpServletRequest req,HttpServletResponse res)
{
String bianhao=req.getParameter("bianhao");
String name=req.getParameter("name");
String sex=req.getParameter("sex");
int age=Integer.parseInt(req.getParameter("age"));
String del="no";
String sql="insert into t_tea(bianhao,name,sex,age,del) values(?,?,?,?,?)";
Object[] params={bianhao,name,sex,age,del};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "tea?type=teaMana");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void teaDel(HttpServletRequest req,HttpServletResponse res)
{
String sql="update t_tea set del='yes' where id="+Integer.parseInt(req.getParameter("id"));
Object[] params={};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "tea?type=teaMana");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void teaMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
List teaList=new ArrayList();
String sql="select * from t_tea where del='no'";
Object[] params={};
DB mydb=new DB();
try
{
{
}
}
public class stu_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
if(type.endsWith("stuAdd"))
{
stuAdd(req, res);
}
if(type.endsWith("stuDel"))
{
stuDel(req, res);
}
if(type.endsWith("stuMana"))
{
stuMana(req, res);
}
if(type.endsWith("stuEdit_stu"))
{
stuEdit_stu(req, res);
}
}