BlogAction.java
上传用户:wlfwy2004
上传日期:2016-12-12
资源大小:33978k
文件大小:2k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. package com.opensource.blog.web.action;
  2. import javax.servlet.http.HttpServletRequest;
  3. import javax.servlet.http.HttpServletResponse;
  4. import org.apache.struts.action.Action;
  5. import org.apache.struts.action.ActionForm;
  6. import org.apache.struts.action.ActionForward;
  7. import org.apache.struts.action.ActionMapping;
  8. import com.laoer.comm.web.PageList;
  9. import com.laoer.comm.web.Pages;
  10. import com.opensource.blog.service.ArticleService;
  11. import com.opensource.blog.service.BlogService;
  12. public class BlogAction
  13.     extends Action {
  14.   private BlogService blogService;
  15.   private ArticleService articleService;
  16.   public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm,
  17.                                HttpServletRequest servletRequest,
  18.                                HttpServletResponse servletResponse) {
  19.     Pages pages = new Pages(servletRequest.getLocale());
  20.     pages.setPage(1);
  21.     pages.setPerPageNum(20);
  22.     pages.setStyle(1);
  23.     pages.setTotals(20);
  24.     pages.setFileName("");
  25.     PageList pl = this.getBlogService().findBlogAll(pages);
  26.     servletRequest.setAttribute("bpl", pl);
  27.     pl = this.getArticleService().findArticlesAll(pages);
  28.     servletRequest.setAttribute("apl", pl);
  29.     return actionMapping.findForward("blog");
  30.   }
  31.   public ArticleService getArticleService() {
  32.     return articleService;
  33.   }
  34.   public BlogService getBlogService() {
  35.     return blogService;
  36.   }
  37.   public void setArticleService(ArticleService articleService) {
  38.     this.articleService = articleService;
  39.   }
  40.   public void setBlogService(BlogService blogService) {
  41.     this.blogService = blogService;
  42.   }
  43. }