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");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
jsp 自学手册 - 新闻网
共185个文件
jar:47个
jpg:40个
jsp:32个
需积分: 0 14 下载量 176 浏览量
2009-05-23
02:24:47
上传
评论
收藏 13.08MB RAR 举报
温馨提示
jsp手册 随书源码 jar包 及数据库 可部署 可运行
资源详情
资源评论
资源推荐
收起资源包目录
jsp 自学手册 - 新闻网 (185个子文件)
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
Thumbs.db 6KB
程序使用说明.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
hibernate3.jar 1.88MB
jgroups-2.2.8.jar 1.54MB
ant-1.6.5.jar 1010KB
xerces-2.6.2.jar 987KB
jboss-jmx.jar 578KB
jboss-common.jar 570KB
struts.jar 514KB
c3p0-0.9.0.jar 476KB
proxool-0.8.3.jar 465KB
antlr-2.7.6rc1.jar 434KB
antlr.jar 379KB
jboss-cache.jar 366KB
log4j-1.2.11.jar 342KB
dom4j-1.6.1.jar 307KB
cglib-2.1.3.jar 276KB
jtds-0.8.1.jar 250KB
jaxen-1.1-beta-7.jar 222KB
jboss-system.jar 218KB
commons-collections-2.1.1.jar 171KB
commons-collections.jar 171KB
concurrent-1.3.2.jar 167KB
cleanimports.jar 139KB
syndiag2.jar 139KB
xml-apis.jar 121KB
junit-3.8.1.jar 118KB
commons-beanutils.jar 116KB
oscache-2.1.jar 112KB
commons-digester.jar 107KB
jaas.jar 102KB
commons-validator.jar 82KB
ant-junit-1.6.5.jar 72KB
jakarta-oro.jar 64KB
ehcache-1.1.jar 46KB
commons-logging.jar 37KB
commons-logging-1.0.4.jar 37KB
swarmcache-1.0rc2.jar 30KB
asm.jar 26KB
jacc-1_0-fr.jar 24KB
commons-fileupload.jar 22KB
connector.jar 18KB
asm-attrs.jar 16KB
ant-launcher-1.6.5.jar 9KB
jta.jar 9KB
ant-swing-1.6.5.jar 7KB
jdbc2_0-stdext.jar 7KB
versioncheck.jar 6KB
ant-antlr-1.6.5.jar 6KB
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
共 185 条
- 1
- 2
LYO1005
- 粉丝: 0
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0