5.3系统主要功能模块详述
5.3.1登录模块
当博主需发表新日志或者是对博客进行管理时,就必须先进行登录验证操作,然后进入博客系统后台。用户登录界面图如图5.3所示。
图5.3 用户登录界面图
public void checkConsumer(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException{ String username=request.getParameter(\ consumerDao=new ConsumerDao();
ConsumerFormconsumerForm=consumerDao.getConsumerForm(username); if(consumerForm==null){
request.setAttribute(\\您输入的用户名不存在,请重新输入!\
}else if (!consumerForm.getPassword().equals(request.getParameter(\
request.setAttribute(\\您输入的登录密码有误,请重新输入!\
}else {
request.setAttribute(\ }
26
request.getRequestDispatcher(\ }
说明:用户在表单中输入用户名和密码,点击“登录”按钮提交到ConsumerServlet后通过验证后进入博客主页。 5.3.2日志管理模块
日志管理显示模块列出了日志标题、日志类型、发表时间以及相应的操作:编辑日志、删除日志和评论日志。根据选择的分类显示当前分类下的日志列表。当然,对日志进行操作的前提条件是当前登录用户具备相应的管理权限。
日志显示界面图如图5.4所示。
图5.4 日志显示界面图
当用户需要添加新的日志时,可单击日志管理显示界面中的写日志链接,进入添加新日志的界面。在日志标题、内容输入域内输入相应的文字,以及选择分类后,单击“确定”按钮进行表单提交,完成添加新日志的操作[14]。 5.3.3撰写日志模块
撰写日志界面图如图5.5所示。
27
图5.5 撰写日志界面图
写日志核心代码:
public void addArticle(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ArticleForm articleForm = new ArticleForm();
articleForm.setTypeId(Integer.parseInt(request.getParameter(\ articleForm.setTitle(request.getParameter(\
articleForm.setNumber(Integer.parseInt(request.getParameter(\ articleForm.setContent(request.getParameter(\ articleForm.setPhTime(request.getParameter(\
articleForm.setUser_id(Integer.parseInt(request.getParameter(\ articleDao =new ArticleDao();
PrintWriter out = response.getWriter(); String result = \文章添加失败!\
if(articleDao.operationArticle(\添加\ out .print(\language=javascript>alert('添加文章成功');window.location.href='article.jsp';\ } }
说明:在标题文本框输入标题名称,在日志类型下拉列表框中选择“文章类型”,在文本域输入文本内容后,点击“提交”按钮提交到ArticleServlet完成日志添加。
28
5.3.4查询日志模块
如果需要查询特定类型的日志可点击日志显示页面右侧的日志类型名,如个人日志类型,如图5.6所示。 日志显示核心代码: public List queryArticle(Integer typeId,Integer user_id){ List list = new ArrayList(); String sql = null; if(typeId == null) sql = \ else sql = \* from tb_article where typeId = '\and user_id = '\ ResultSet rs = connection.executeQuery(sql); try { while(rs.next()) { articleForm = new ArticleForm(); articleForm.setId(rs.getInt(\ articleForm.setTypeId(rs.getInt(\ articleForm.setTitle(rs.getString(\ articleForm.setContent(rs.getString(\ articleForm.setPhTime(rs.getString(\
articleForm.setNumber(Integer.parseInt(rs.getString(\ list.add(articleForm); } } catch (SQLException e) { e.printStackTrace(); } return list; }
29
图5.6 日志查询图
5.3.5日志编辑模块
日志编辑界面图如图5.7所示
图5.7 日志编辑界面图
日志编辑核心代码:
public void updateArticle(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException {
//response.setContentType(\ PrintWriter out = response.getWriter();
ArticleForm articleForm = new ArticleForm();
articleForm.setId(Integer.parseInt(request.getParameter(\ articleForm.setTypeId(Integer.parseInt(request.getParameter(\
30
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库基于J2EE的博客网站论文(7)在线全文阅读。
相关推荐: