计算机毕业设计 jsp数据结构教学网站(ssh) 毕设

本文详细描述了一个系统实现过程,包括管理员登录验证、不同角色的功能模块(如课程介绍管理、教师信息管理、学生信息管理、公告信息管理等),以及前台网站的首面设计和教学资源下载功能。

第5章 系统实现


https://www.bilibili.com/video/BV19i4y1e73H/


演示视频:3.1管理员登录

1.描述:为了保证系统的安全性,要先使用本系统必须先登陆到系统中,用户需要正确的账号和密码登录本系统。

2.程序运行效果图如图3.1所示:

图3.1 系统登陆页面设计

3.在登陆页面输入用户名和密码以,点击提交按钮,跳转到登陆的service中,在该service中会对用户名密码,验证码进行判断,验证通过进入对应的页面,loginservice关键代码:

public String login(String userName,String userPw,int userType)

{

String result="no";

if(userType==0)//系统管理员登陆

{

String sql="from TAdmin where userName=? and userPw=?";

Object[] con={userName.trim(),userPw.trim()};

List adminList=adminDAO.getHibernateTemplate().find(sql,con);

if(adminList.size()==0)

{

 result="no";

}

else

{

 WebContext ctx = WebContextFactory.get();

 HttpSession session=ctx.getSession();

 TAdmin admin=(TAdmin)adminList.get(0);

 session.setAttribute("userType", 0);

             session.setAttribute("admin", admin);

             result="yes";

}

}

if(userType==1)//老师登陆

{

String sql="from TTea where loginName=? and loginPw=? and del='no'";

Object[] con={userName.trim(),userPw.trim()};

List teaList=teaDAO.getHibernateTemplate().find(sql,con);

if(teaList.size()==0)

{

 result="no";

}

else

{

 WebContext ctx = WebContextFactory.get();

 HttpSession session=ctx.getSession();

 TTea tea=(TTea) teaList.get(0);

 session.setAttribute("userType", 1);

             session.setAttribute("tea", tea);

             result="yes";

}

}

if(userType==2)//学生登陆

{

String sql="from TStu where stuXuehao=? and loginPw=? and del='no' and zhuangtai='b'";

Object[] con={userName.trim(),userPw.trim()};

List stuList=stuDAO.getHibernateTemplate().find(sql,con);

if(stuList.size()==0)

{

 result="no";

}

else

{

 WebContext ctx = WebContextFactory.get();

 HttpSession session=ctx.getSession();

 TStu stu=(TStu) stuList.get(0);

 session.setAttribute("userType", 2);

             session.setAttribute("stu", stu);

             result="yes";

}

}

return result;

}

3.2管理员功能模块

1.描述:系统主页面:左方页面展示了管理员可操作的六大功能,进入相关的管理页面可以链接到子菜单,并且高亮显示,每个管理模块下面都有相应的子菜单。

2.程序运行效果图如图3.2所示:

图3.2管理员主页面

在每个jsp页面将会对相关用户进行拦截操作,这样可以提高安全性,防止用户不经过登陆页面而进入任何子菜单页面:

if(session.getAttribute("user")==null)

{

 out.print("");

}

3.2.1课程介绍管理

3.2.1.1课程介绍管理

1.描述:管理员点击左侧的菜单“课程介绍”,页面跳转到课程介绍管理界面,调用后台的action类查询所有班级信息。

2.程序效果图如下图3.4所示

图3.4 课程介绍管理

课程介绍管理关键代码:

public String kechengjieshaoMana()

{

String sql="from TXinxi where leixing='kechengjieshao'";

List list=xinxiDAO.getHibernateTemplate().find(sql);

HttpServletRequest request=ServletActionContext.getRequest();

request.setAttribute("kechengjieshao", list.get(0));

return ActionSupport.SUCCESS;

}

public String kechengjieshaoEdit()

{

String sql="update TXinxi set neirong=? where leixing='kechengjieshao'";

Object[] c={neirong};

xinxiDAO.getHibernateTemplate().bulkUpdate(sql,c);

HttpServletRequest request=ServletActionContext.getRequest();

request.setAttribute("msg", "修改成功");

return "msg";

}

public String kechengjieshaoShow()

{

String sql="from TXinxi where leixing='kechengjieshao'";

List list=xinxiDAO.getHibernateTemplate().find(sql);

HttpServletRequest request=ServletActionContext.getRequest();

request.setAttribute("kechengjieshao", list.get(0));

return ActionSupport.SUCCESS;

}

3.2.2教师信息管理

3.2.2.1教师信息录入

1.描述:管理员输入教师相关正确信息后点击录入按钮,如果是没有输入完整的教师经理信息,都会给出相应的错误提示,不能录入成功。输入数据都通过form表单中定义的方法onsubmit="return checkForm()"来检查,checkForm()函数中是各种的校验输入数据的方式。

2.程序效果图如下图3.6所示:

图3.6 教师信息录入

3.2.2.2教师信息管理

1.描述:管理员点击左侧的菜单“教师管理”,页面跳转到教师管理界面,调用后台的action类查询所有教师信息。

2.程序效果图如下图3.7所示

图3.7 教师信息管理

教师管理关键代码:

public String teaAdd()

{

TTea tea=new TTea();

tea.setTeaBianhao(teaBianhao);

tea.setLoginName(loginName);

tea.setLoginPw(loginPw);

tea.setTeaRealname(teaRealname);

tea.setTeaSex(teaSex);

tea.setTeaAge(teaAge);

tea.setDel("no");

teaDAO.save(tea);

this.setMessage("操作成功");

this.setPath("teaMana.action");

return "succeed";

}

public String teaMana()

{

String sql="from TTea where del='no'";

List teaList=teaDAO.getHibernateTemplate().find(sql);

Map request=(Map)ServletActionContext.getContext().get("request");

request.put("teaList", teaList);

return ActionSupport.SUCCESS;

}

public String teaDel()

{

TTea tea=teaDAO.findById(teaId);

tea.setDel("yes");

teaDAO.attachDirty(tea);

this.setMessage("操作成功");

this.setPath("teaMana.action");

return "succeed";

}

3.2.3学生信息管理

3.2.3.1学生信息录入

1.描述:管理员输入学生相关正确信息后点击录入按钮,如果是没有输入完整的学生经理信息,都会给出相应的错误提示,不能录入成功。输入数据都通过form表单中定义的方法onsubmit="return checkForm()"来检查,checkForm()函数中是各种的校验输入数据的方式。

2.程序效果图如下图3.9所示:

图3.9 学生信息录入

3.2.2.2学生信息管理

1.描述:管理员点击左侧的菜单“学生管理”,页面跳转到学生管理界面,调用后台的action类查询所有学生信息。

2.程序效果图如下图3.10所示

图3.10 学生信息管理

学生管理关键代码:

public String stuAdd()

{

TStu stu=new TStu();

stu.setStuXuehao(stuXuehao);

stu.setStuRealname(stuRealname);

stu.setStuSex(stuSex);

stu.setStuAge(stuAge);

stu.setLoginPw(loginPw);

stu.setZhuangtai("a");

stu.setDel("no");

stuDAO.save(stu);

this.setMessage("操作成功");

this.setPath("stuMana.action");

return "succeed";

}

public String stuMana()

{

List stuList=stuDAO.getHibernateTemplate().find("from TStu where del='no'");

Map request=(Map)ServletActionContext.getContext().get("request");

request.put("stuList", stuList);

return ActionSupport.SUCCESS;

}

public String stuDel()

{

TStu stu=stuDAO.findById(stuId);

stu.setDel("yes");

stuDAO.attachDirty(stu);

this.setMessage("删除成功");

this.setPath("stuMana.action");

return "succeed";

}

3.2.4公告信息管理

3.2.3.1公告信息录入

1.描述:管理员输入公告相关正确信息后点击录入按钮,如果是没有输入完整的公告信息,都会给出相应的错误提示,不能录入成功。输入数据都通过form表单中定义的方法onsubmit="return checkForm()"来检查,checkForm()函数中是各种的校验输入数据的方式。

2.程序效果图如下图3.12所示:

图3.12 公告信息录入

3.2.3.2公告信息管理

1.描述:管理员点击左侧的菜单“公告信息管理”,页面跳转到公告信息管理界面,调用后台的action类查询出所有的公告信息,并把这些信息封转到数据集合List中,绑定到request对象,然后页面跳转到相应的jsp,显示出公告信息。

2.程序效果图如下图3.13所示

图3.13 公告信息管理页面

公告信息管理关键代码:

public String gonggaoAdd()

{

TGonggao gonggao=new TGonggao();

gonggao.setGonggaoTitle(gonggaoTitle);

gonggao.setGonggaoContent(gonggaoContent);

gonggao.setGonggaoData(new Date().toLocaleString());

gonggaoDAO.save(gonggao);

this.setMessage("公告添加完毕");

this.setPath("gonggaoMana.action");

return "succeed";

}

public String gonggaoMana()

{

List gonggaoList =gonggaoDAO.findAll();

Map request=(Map)ServletActionContext.getContext().get("request");

request.put("gonggaoList", gonggaoList);

return ActionSupport.SUCCESS;

}

public String gonggaoDel()

{

TGonggao gonggao=gonggaoDAO.findById(gonggaoId);

gonggaoDAO.delete(gonggao);

this.setMessage("公告删除完毕");

this.setPath("gonggaoMana.action");

return "succeed";

}

public String gonggaoDetail()

{

TGonggao gonggao=gonggaoDAO.findById(gonggaoId);

Map request=(Map)ServletActionContext.getContext().get("request");

request.put("gonggao", gonggao);

return ActionSupport.SUCCESS;

}

3.2.3.3公告详细信息查看

1.描述:先是点击公告信息管理,页面跳转到公告信息管理界面,浏览所有的公告信息,点击要查看的公告信息,弹出公告信息详细信息界面。

3.2.3.4公告信息删除

1.描述:先是点击公告信息管理,页面跳转到公告信息管理界面,浏览所有的公告信息,点击要删除的公告信息,弹出的确定对话框,即可删除该公告信息。

3.3前台网站功能模块

3.3.1网站首面设计

1.描述:前台首页是浏览者打开一个网站后第一眼看到的网页,网站能不能吸引浏览者,在很大程度上取决于首页做得怎么样。首页包含内容虽然丰富但不杂乱,色彩搭配要合理,整体风格要独特。

2.程序效果图如下图3.22所示:

图3.22 网站首页

3.3.2教学课件下载

1. 描述:点击网站主页菜单的课件信息菜单,进入课件信息列表,点击课件信息具体内容,并下载资料中的附件信息。

2.程序效果图如下图3.23所示:

图3.23 教学课件下载

课件下载核心代码:

public String docAll()

{

String sql="from TDoc where del='no'";

List docList=docDAO.getHibernateTemplate().find(sql);

Map request=(Map)ServletActionContext.getContext().get("request");

request.put("docList", docList);

return ActionSupport.SUCCESS;

}

public String docDetailQian()

{

TDoc doc=docDAO.findById(id);

Map request=(Map)ServletActionContext.getContext().get("request");

request.put("doc", doc);

return ActionSupport.SUCCESS;

}

3.3.3教学视频下载

1. 描述:点击网站主页菜单的教学视频,进入教学视频信息列表,点击视频信息浏览具体内容,并下载视频中的附件信息。

2.程序效果图如下图3.24所示:

图3.24 教学视频下载

教学视频下载关键代码:

String fujianPath=request.getParameter("fujianPath");

String fujianYuashiMing=request.getParameter("fujianYuashiMing");

          fujianYuashiMing=java.net.URLDecoder.decode(fujianYuashiMing,"UTF-8");

System.out.println(fujianYuashiMing+fujianPath);

SmartUpload su = new SmartUpload(); // 新建一个SmartUpload对象

su.initialize(pageContext); // 初始化

su.setContentDisposition(null);

// 设定contentDisposition为null以禁止浏览器自动打开文件,

//保证点击链接后是下载文件。若不设定,则下载的文件扩展名为

//doc时,浏览器将自动用word打开它。扩展名为pdf时,将用acrobat打开

//response.sendRedirect(path+"/updown/updown_err.jsp");

//su.downloadFile("/uploadPath/file/liu.doc"); // 下载英文文件

su.downloadFile(fujianPath, null, new String(fujianYuashiMing.getBytes(), "ISO8859-1")); // 下载中文文件

//downloadFile(String sourceFilePathName, String contentType, String destFileName)

out.clear();

out=pageContext.pushBody();

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值