package com.action;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForward;
import com.actionForm.NewsForm;
import org.apache.struts.actions.DispatchAction;
import com.dao.ObjectDao;
import com.tools.TimeShow;
import java.io.UnsupportedEncodingException;
import java.util.List;
public class NewsAction extends DispatchAction
{
private ObjectDao<NewsForm> objectDao = null;
// 后台:按新闻大类别的名称查询信息的Action
public ActionForward queryNewsListAction(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response)
throws UnsupportedEncodingException
{
objectDao = new ObjectDao<NewsForm>();
String bigSort = request.getParameter("bigSort");
bigSort = new String(bigSort.getBytes("ISO8859_1"), "gb2312");
String hql = "from NewsForm where bigSort='" + bigSort
+ "' order by id desc";
List list = objectDao.queryList(hql);
request.setAttribute("list", list);
return mapping.findForward("selectAllNews");
}
// 后台:新闻添加的Action
public ActionForward insertNewsAction(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response)
throws UnsupportedEncodingException
{
objectDao = new ObjectDao<NewsForm>();
NewsForm newsForm = (NewsForm) form;
newsForm.setShowNews(com.tools.TimeShow.autoNumber());
objectDao.saveT(newsForm);
request.setAttribute("newsForm", newsForm);
return mapping.findForward("resultNewsAction");
}
// 后台: 对新闻的详细查询,转向修改页面Action
public ActionForward selectOneNewsAction(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response)
throws UnsupportedEncodingException
{
objectDao = new ObjectDao<NewsForm>();
int id = Integer.parseInt(request.getParameter("id"));
String hql = "from NewsForm where id=" + id + "";
NewsForm newsForm = objectDao.queryFrom(hql);
request.setAttribute("form", newsForm);
return mapping.findForward("selectOneNewsAction");
}
// 后台:对新闻的修改Action
public ActionForward updateNewsAction(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response)
throws UnsupportedEncodingException
{
NewsForm newsForm = (NewsForm) form;
objectDao = new ObjectDao<NewsForm>();
String hql = "from NewsForm where id=" + newsForm.getId() + "";
NewsForm nform = objectDao.queryFrom(hql);
String filename = request.getRealPath("newsContent\\"
+ nform.getShowNews());
com.tools.FileOperation.deleteFile(filename);
/** ************************************** */
newsForm.setShowNews(com.tools.TimeShow.autoNumber());
objectDao.updateT(newsForm);
request.setAttribute("newsForm", newsForm);
return mapping.findForward("resultNewsAction");
}
// 后台:对新闻的删除Action
public ActionForward deleteNewsAction(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response)
throws UnsupportedEncodingException
{
objectDao = new ObjectDao<NewsForm>();
int id = Integer.parseInt(request.getParameter("id"));
String hql = "from NewsForm where id=" + id + "";
NewsForm newsForm = objectDao.queryFrom(hql);
objectDao.deleteT(newsForm);
request.setAttribute("result", "新闻删除成功");
String filename = request.getRealPath("newsContent\\"
+ newsForm.getShowNews());
com.tools.FileOperation.deleteFile(filename);
return mapping.findForward("resultNewsAction");
}
// 后台:对新闻的详细查询
public ActionForward queryNewsFormAction(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response)
throws UnsupportedEncodingException
{
objectDao = new ObjectDao<NewsForm>();
int id = Integer.parseInt(request.getParameter("id"));
String hql = "from NewsForm where id=" + id + "";
NewsForm newsForm = objectDao.queryFrom(hql);
request.setAttribute("form", newsForm);
return mapping.findForward("queryNewsFormAction");
}
// 前台:对新闻的查看
public ActionForward front_queryNewsAction(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response)
throws UnsupportedEncodingException
{
objectDao = new ObjectDao<NewsForm>();
String hql = "";
String sign = request.getParameter("sign");
sign = new String(sign.getBytes("ISO8859_1"), "gb2312");
hql = "from NewsForm where bigSort = '" + sign + "'"; // 设置新闻类别的HQL语句
if (sign.equals("今日新闻")) // 对今日新闻的查询
{
TimeShow timeShow = new TimeShow();
String currtime = timeShow.cuttentMonthDate();
hql = "from NewsForm where createTime = '" + currtime
+ "'";
}
List list = objectDao.queryList(hql);
request.setAttribute("list", list);
return mapping.findForward("front_queryNewsAction");
}
// 前台:对新闻关键字的查询
public ActionForward front_queryKeyNewsAction(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response)
throws UnsupportedEncodingException
{
objectDao = new ObjectDao<NewsForm>();
String key = request.getParameter("key").trim();
String hql = "from NewsForm where (title like '%" + key
+ "%') or (content like '%" + key + "%')";
List list=objectDao.queryList(hql);
request.setAttribute("list", list);
return mapping.findForward("front_queryKeyNewsAction");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
完整全面的新闻系统,很好很强大
共137个文件
jpg:40个
jsp:32个
java:14个
需积分: 3 3 下载量 170 浏览量
2010-11-16
19:01:33
上传
评论 1
收藏 1.7MB RAR 举报
温馨提示
新闻系统,里面加入了Hibernate,Spring,SQLSERVER等相关技术,很好很全面,还等什么,赶紧下载吧
资源推荐
资源详情
资源评论
收起资源包目录
完整全面的新闻系统,很好很强大 (137个子文件)
NewsAction.class 5KB
ForceAction.class 4KB
ManagerAction.class 4KB
ObjectDao.class 4KB
SortAction.class 3KB
AfficheAction.class 2KB
NewsForm.class 2KB
ManagerForm.class 1KB
SortForm.class 1KB
ForceForm.class 1KB
TimeShow.class 1KB
AfficheForm.class 998B
SelfRequestProcessor.class 918B
FileOperation.class 549B
style.css 4KB
程序使用说明.doc 685KB
new.gif 6KB
land.gif 1KB
reset.gif 1KB
search.gif 411B
template.htm 1KB
1209104957906.html 2KB
1209104979718.html 2KB
1209104999859.html 2KB
1209105018531.html 2KB
1209109274671.html 2KB
1209181614640.html 1KB
NewsAction.java 6KB
ForceAction.java 4KB
ManagerAction.java 3KB
SortAction.java 2KB
ObjectDao.java 2KB
AfficheAction.java 2KB
NewsForm.java 1KB
ManagerForm.java 1KB
SortForm.java 959B
ForceForm.java 878B
AfficheForm.java 642B
SelfRequestProcessor.java 621B
TimeShow.java 483B
FileOperation.java 255B
b_top.jpg 117KB
land_top.jpg 71KB
f_right3.jpg 69KB
f_tadayNews.jpg 62KB
f_top3.jpg 61KB
f_funNews.jpg 56KB
f_economyNews.jpg 56KB
f_politicsNews.jpg 56KB
f_lawNews.jpg 55KB
f_scienceNews.jpg 55KB
f_societyNews.jpg 53KB
f_left4.jpg 52KB
f_force.jpg 51KB
f_reach.jpg 49KB
b_mainPage.jpg 48KB
f_botton.jpg 48KB
b_bottom.jpg 41KB
f_top2.jpg 38KB
b_right.jpg 38KB
land_right.jpg 35KB
f_left2.jpg 30KB
f_right5.jpg 27KB
f_right2.jpg 27KB
f_right4.jpg 27KB
f_left11.jpg 24KB
b_place.jpg 23KB
land_left.jpg 20KB
news_top.jpg 20KB
f_right1.jpg 18KB
b_bottom1.jpg 18KB
f_top4.jpg 16KB
f_background1.jpg 15KB
f_background.jpg 15KB
b_leftButton.jpg 15KB
news_button.jpg 15KB
f_left13.jpg 14KB
f_top1.jpg 13KB
f_left12.jpg 13KB
news_middle.jpg 13KB
f_left3.jpg 7KB
menu.JS 9KB
validate.JS 1KB
index.jsp 13KB
b_queryNewsList.jsp 5KB
f_left.jsp 4KB
b_newsUpdate.jsp 4KB
b_querySortList.jsp 4KB
b_forceSelect.jsp 4KB
f_queryNews.jsp 4KB
b_newsInsert.jsp 4KB
b_afficheSelect.jsp 4KB
b_newsContent.jsp 3KB
b_forceUpdate.jsp 3KB
b_managerQueryList.jsp 3KB
f_queryForceList.jsp 3KB
b_forceInsert.jsp 3KB
b_sortInsert.jsp 3KB
b_managerUpdate.jsp 3KB
b_afficheInsert.jsp 3KB
共 137 条
- 1
- 2
资源评论
tianhan361315525
- 粉丝: 1
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于SpringBoot Mybatis-Plus TypeScript的微服务多租户SaaS管理快速开发框架 .zip
- 论文复现:QA-GNN: Reasoning with Language Models and Knowledge
- ipp(intel-oneAPI)下载地址.txt
- 基于spring-boot dubbox搭建的java分布式系统的前端管理.zip
- VLC+Qt demoVLC+Qt demo
- 海彪&龙梅子 - 寂寞的人伤心的歌 (DJ版) [mqms2].ogg
- 530springboot + vue 旅游管理系统.zip(可运行源码+数据库文件+文档)
- 基于SpringBoot + Thymeleaf + Layui + Apache Shiro 的后台管理系统 .zip
- 表1:长江大学文理学院课外学分申请表.et
- base.apk
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功