基于javaweb和mysql的jsp+servlet高校教学评价管理系统(java+jsp+javascript+servlet+mysql)
私信源码获取及调试交流
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的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
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 pingjia_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
Object[] params = {userPwNew, admin.getUserId()};
DB mydb = new DB();
mydb.doPstm(sql, params);
return "yes";
}
}
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);
}
}
mydb.doPstm(sql, params);
return "yes";
}
}
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");
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()
{
}
}
{
pingjiaMana(req, res);
}
}
public void pingjiaAdd(HttpServletRequest req,HttpServletResponse res)
{
String pingjia_id=String.valueOf(new Date().getTime());
int tea_id=Integer.parseInt(req.getParameter("tea_id"));
int zongfenshu=0;
String shijian=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date());
//int stu_id=((Tstu)(req.getSession().getAttribute("stu"))).getId();
int stu_id = loginService.currentStudentId;
if("yipingjia".equals(liuService.panduan_shifou_pingjia(tea_id, stu_id)))
{
req.setAttribute("msg", "你已经评价过该老师。不能重发评价");
}
if("weipingjia".equals(liuService.panduan_shifou_pingjia(tea_id, stu_id)))
{
String zhibiao_id=req.getParameter("zhibiao_id");
String[] zhibiao_id1=zhibiao_id.split(",");
for(int i=0;i<zhibiao_id1.length;i++)
{
int zhibiao_id2=Integer.parseInt(zhibiao_id1[i]);
int fenshu=Integer.parseInt(req.getParameter(String.valueOf(zhibiao_id2)));
zongfenshu+=fenshu;
System.out.println(zhibiao_id2+"^^"+fenshu);
liuService.save_pingjia_xuanxiang(zhibiao_id2, fenshu, pingjia_id);
}
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
{
req.getRequestDispatcher("admin/admin/adminMana.jsp").forward(req, res);
}
public void adminAdd(HttpServletRequest req,HttpServletResponse res)
{
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)
{
}
public void teaAll(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.setAttribute("teaList", teaList);
req.getRequestDispatcher("admin/tea/teaAll.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)
{
public void teaAll(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.setAttribute("teaList", teaList);
req.getRequestDispatcher("admin/tea/teaAll.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)
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.setAttribute("teaList", teaList);
req.getRequestDispatcher("admin/tea/teaMana.jsp").forward(req, res);
}
public void teaAll(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();
{
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 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();
}
{
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.setAttribute("teaList", teaList);
req.getRequestDispatcher("admin/tea/teaMana.jsp").forward(req, res);
}
public void teaAll(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.setAttribute("teaList", teaList);
req.getRequestDispatcher("admin/tea/teaAll.jsp").forward(req, res);
}
public void stuMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
List stuList=new ArrayList();
String sql="select * from t_stu where del='no'";
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
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");
}
}
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);
}
}
public void stuAdd(HttpServletRequest req,HttpServletResponse res)
{
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
{
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()
{
}
}
}
mydb.closed();
req.setAttribute("teaList", teaList);
req.getRequestDispatcher("admin/tea/teaMana.jsp").forward(req, res);
}
public void teaAll(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.setAttribute("teaList", teaList);
req.getRequestDispatcher("admin/tea/teaAll.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)
}
}
public class pingjia_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
if(type.endsWith("pingjiaAdd"))
{
pingjiaAdd(req, res);
}
if(type.endsWith("pingjiaMana"))
{
pingjiaMana(req, res);
}
}
public void pingjiaAdd(HttpServletRequest req,HttpServletResponse res)
{
String pingjia_id=String.valueOf(new Date().getTime());
int tea_id=Integer.parseInt(req.getParameter("tea_id"));
int zongfenshu=0;
String shijian=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date());
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={};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");









357

被折叠的 条评论
为什么被折叠?



