📄 indexaction.java
字号:
package com.yhcms.index.action;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.yhcms.artclass.bean.ArtClass;
import com.yhcms.artclass.dao.ArtClassDaoIm;
import com.yhcms.artclass.itface.ArtClassDao;
import com.yhcms.article.dao.ArticleDaoIm;
import com.yhcms.article.itface.ArticleDao;
import com.yhcms.cmsinfo.dao.CmsInfoDaoIm;
import com.yhcms.cmsinfo.itface.CmsInfoDao;
import com.yhcms.db.DBConnException;
import com.yhcms.index.bean.IndexTwoClass;
import com.yhcms.note.dao.NoteDaoIm;
import com.yhcms.note.itface.NoteDao;
/**
* <p>Title:系统首页Action</p>
* <li>系统首页</li>
* <br><b>CopyRight: yyhweb[由由华网]</b>
* @author stephen
* @version YH-2.0
*/
public class IndexAction extends Action {
public ActionForward execute(ActionMapping actionmapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response){
Logger yhlog = Logger.getLogger(IndexAction.class.getName());
List newList = null; // 最新文章列表
List cList = null; // 搜索选择栏目列表
List artlist = null; // 文章列表
List calist = new ArrayList(); // 栏目和该栏目下文章列表
List llist = null; // 友情链接列表
IndexTwoClass indexClass = null; // indexClass 属性
int i = 0;
int cid = 0;
String cname = "";
ArticleDao artdao = ArticleDaoIm.getInstance(); // 文章操作
ArtClassDao classdao = ArtClassDaoIm.getInstance();// 栏目操作
CmsInfoDao cmdao = CmsInfoDaoIm.getInstance(); // 系统属性操作
NoteDao notedao = NoteDaoIm.getInstance();
List nlist = null; // 只取得系统最新留言
ArtClass tempClass = null; // 临时栏目
try {
newList = artdao.getNewArts(8); // 最新文章
cList = classdao.getAllInClass(); // 文章内部栏目
llist = cmdao.getCheckedLink(); // 友情链接
nlist = notedao.getNewNotes(6);
for(i=0;i<2;i++){ // 取得系统前两个栏目和其下最新文章
indexClass = new IndexTwoClass();
// 取得系统内部栏目
tempClass = (ArtClass) cList.get(i);
cid = tempClass.getId();
cname = tempClass.getName();
artlist = artdao.getIndexArt(cid, 0, 8);
// 设置首页要显示栏目的属性
indexClass.setCid(cid);
indexClass.setCname(cname);
indexClass.setArtlist(artlist);
calist.add(indexClass);
}
} catch (DBConnException e) {
yhlog.warn("When the index page display,throw an Exception!");
}
request.setAttribute("newList",newList);
request.setAttribute("cList",cList);
request.setAttribute("cartList",calist);
request.setAttribute("linkList",llist);
request.setAttribute("noteList",nlist);
return actionmapping.findForward("Index");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -