《新闻发布系统》设计报告.docx
《《新闻发布系统》设计报告.docx》由会员分享,可在线阅读,更多相关《《新闻发布系统》设计报告.docx(18页珍藏版)》请在冰豆网上搜索。
![《新闻发布系统》设计报告.docx](https://file1.bdocx.com/fileroot1/2022-10/28/b3e59db9-074f-4d76-ab5b-db6c22e8a52c/b3e59db9-074f-4d76-ab5b-db6c22e8a52c1.gif)
《新闻发布系统》设计报告
陕西师范大学远程教育学院考查课
科目《动态网页制作》设计报告
题目在线新闻发布系统
姓名
学号
专业计算机应用技术
批次
层次高起专
学习中心_陕西延川职业教育中心
《在线新闻发布系统》课程设计报告
一、设计时间
2013年6月04日-----11月08日
二、设计地点
延川职教中心学校
三、设计目的
1、巩固学习Web基础知识方面的基本算法,进一步熟悉基本概念。
2、熟练常用软件及JAVA语言等方面的操作,了解基本的流程。
3、运用所用学的JAVA语言知识,编写出较为实用的网页系统,增进对一些实际问题的软,硬件知识的掌握。
4、培养查阅资料,养成独立思考解决问题的能力。
四、设计小组成员
......
五、指导老师
...老师
六、设计课题
编写实现一个新闻发布系统
七、基本思路及关键问题的解决方法
基本思路:
新闻发布系统是一个功能齐全的新闻网页,本系统基于B/S模式,服务端采用JSP进行动态开发,系统主要包含三个部分:
前台系统:
此部分主要包括新闻查看,新闻信息查询以及登录模块。
后台系统:
此部分主要包括管理员基本信息的设置以及新闻基本分类及信息管理、后台退出。
数据库部分:
数据库主要存放用户所有信息,在管理员和普通用户登陆过程中都有登陆的信息确认过程,确认密码是否与原服务器上的一致,只有一致的时候才能登陆成功,否则失败。
当修改信息的时候也会有这样的确认过程,确保信息的正确性和有效性。
八、算法及流程图
(一)新闻系统功能结构图
(二)系统流程图
后台流程:
九、调试过程中出现的问题及相应解决办法
4详细设计
4.1前台系统
4.1.1新闻的查看
主页面如下图
图4-1系统主页界面效果
任何用户在浏览器输入网址后进入本站界面,即可查看新闻标题及发布时间,新闻的评论、新闻的点击率等,单击任意一条新闻标题即可查看新闻内容。
图4-2新闻内容界面效果
显示一条新闻的主要代码为:
<%
request.setCharacterEncoding("gbk");
SearchNewssh=newSearchNews();
Newsn=sh.getNews
(1);
if(n!
=null)
{
%>
<%out.println(n.getBiaoti());%>
<%out.print(n.getFabushijian());%>
<%out.println(n.getLaiyuan());%>
<%out.println(n.getZhaiyao());%>
<%out.println(n.getTupian());%>
<%out.println(StringToHtml.toHtml(n.getZhengwen()));%>
<%out.println(n.getGuanjianzi());%>
<%out.println(n.getFabiaozhe());%>
<%out.println(n.getClassid());%>
<%out.println(n.getDianjilv());%>
<%}%>
<%out.println(n.getBanquanxinxi());%>
<%if(n.getComcount()!
=0){%>
newid=<%out.print(n.getNewsid());%>">评论
<%out.print(n.getComcount());%>条>>
<%}else{%>评论
<%out.print(n.getComcount());%>条>><%}%>
我要留言:
"/>
4.1.2评论功能的实现
评论管理的数据流图如下
图4-3评论管理数据流图
评论与浏览页面:
图4-4评论浏览添加评论页面
评论实现的事务处理相关代码:
protectedvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{
//TODOAuto-generatedmethodstub
doPost(request,response);
}
/**
*@seeHttpServlet#doPost(HttpServletRequestrequest,HttpServletResponseresponse)
*/
protectedvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{
//TODOAuto-generatedmethodstub
request.setCharacterEncoding("gbk");
response.setCharacterEncoding("gbk");
intnewsid=Integer.parseInt(request.getParameter("newsid"));
Stringcomment=request.getParameter("commenttext");
Stringcomperson=request.getParameter("person");
Stringtype=request.getParameter("type");
PrintWriterpw=response.getWriter();
pw.println(newsid);
pw.println(comment);
Commentcomm=newComment();
comm.setContext(comment);
comm.setNewid(newsid);
comm.setComPerson(comperson);
intresult=ModifComment.insert(comm);
if(type.equals("new"))
{
response.sendRedirect("oneofnews.jsp?
newid="+newsid);
}
elseif(type.equals("comment"))
{
response.sendRedirect("commentofnew.jsp?
newid="+newsid);
}
elseif(type.equals("admincomment"))
{
response.sendRedirect("admin\\admin_commentview.jsp?
newid="+newsid);
}
}
添加一条评论的代码为:
publicclassInsertComment{
publicstaticvoidinsert(Commentcomment)
{
DBConnectPooldbp=DBConnectPool.getInstance();
Connectionconn=dbp.getConnection();
PreparedStatementpstmt=null;
try{
pstmt=conn.prepareStatement("inserintocommentvalues(?
?
?
?
)");
pstmt.setInt(1,comment.getNewid());
pstmt.setDate(2,(java.sql.Date)(newDate()));
pstmt.setString(3,comment.getComPerson());
pstmt.setString(4,comment.getContext());
pstmt.executeUpdate();
}catch(SQLExceptione1){
//TODOAuto-generatedcatchblock
e1.printStackTrace();
}finally
{
try
{
if(pstmt!
=null)
pstmt.close();
}catch(SQLExceptionel)
{
el.printStackTrace();
}
}
}
}
4.2后台管理系统的设计
4.2.1后台登陆模块
图4-5后台登陆界面
当用户在对话框输入正确的用户名、密码及随机产生的验证码时,进入后台页面lf.jsp,否则回到登陆页面login.jsp并提示原因。
登录事务处理相关代码如下:
protectedvoiddoGet(HttpServletRequestrequest,
HttpServletResponseresponse)throwsServletException,IOException{
//TODOAuto-generatedmethodstub
doPost(request,response);
}
/**
*@seeHttpServlet#doPost(HttpServletRequestrequest,HttpServletResponse
*response)
*/
protectedvoiddoPost(HttpServletRequestrequest,
HttpServletResponseresponse)throwsServletException,IOException{
request.setCharacterEncoding("gbk");
response.setCharacterEncoding("gbk");
Stringusername=request.getParameter("name");
Stringpasswd=request.getParameter("pass");
booleanflag=false;
Useruser=