LeaveAction.java
上传用户:yunfeng252
上传日期:2022-07-23
资源大小:12403k
文件大小:3k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. package org.yufeng.struts.action;
  2. import java.util.List;
  3. import javax.servlet.http.HttpServletRequest;
  4. import javax.servlet.http.HttpServletResponse;
  5. import javax.servlet.http.HttpSession;
  6. import org.apache.struts.action.ActionForm;
  7. import org.apache.struts.action.ActionForward;
  8. import org.apache.struts.action.ActionMapping;
  9. import org.yufeng.domains.Leaves;
  10. import org.yufeng.service.ILeavesServiceDao;
  11. import org.yufeng.utils.PageService;
  12. import org.yufeng.utils.Tools;
  13. public class LeaveAction extends BaseAction {
  14. Leaves leaves = new Leaves();
  15. Tools tool = new Tools();
  16. public ActionForward add(ActionMapping mapping, ActionForm form,
  17. HttpServletRequest request, HttpServletResponse response) {
  18. HttpSession session = request.getSession();
  19. ILeavesServiceDao leavesService = (ILeavesServiceDao) this
  20. .getleavesService();
  21. leaves.setLe_names(request.getParameter("le_names"));
  22. leaves.setLe_qq(request.getParameter("le_qq"));
  23. leaves.setLe_email(request.getParameter("le_email"));
  24. leaves.setLe_content(request.getParameter("le_content"));
  25. leaves.setLe_puttime(tool.getData());
  26. leaves.setLe_ip(request.getRemoteAddr());
  27. leavesService.addLeaves(leaves);
  28. session.setAttribute("message","留言反馈成功!");
  29. return mapping.findForward("article_leaves");
  30. }
  31. public ActionForward select(ActionMapping mapping, ActionForm form,
  32. HttpServletRequest request, HttpServletResponse response) {
  33. ILeavesServiceDao leavesService = (ILeavesServiceDao) this
  34. .getleavesService();
  35. HttpSession session = request.getSession();
  36. List alllist = leavesService.browseALeaves();
  37. PageService page = new PageService();
  38. //设置请求分页号
  39. String pageId = request.getParameter("pageId");
  40. List leaves = page.getPage(pageId,5,alllist);
  41. String footer = page.getPageFooter(request.getRequestURI(), "select");
  42. session.setAttribute("footer", footer);
  43. request.getSession().setAttribute("leaves", leaves);
  44. return mapping.findForward("admin_atricle_leave");
  45. }
  46. public ActionForward delete(ActionMapping mapping, ActionForm form,
  47. HttpServletRequest request, HttpServletResponse response) {
  48. ILeavesServiceDao leavesService = (ILeavesServiceDao) this
  49. .getleavesService();
  50. String[] ids = request.getParameterValues("le_id");
  51. for (int i = 0; i < ids.length; i++) {
  52. leaves.setLe_id(new Integer(ids[i]));
  53. leavesService.delLeaves(leaves);
  54. this.select(mapping, form, request, response);
  55. }
  56. return mapping.findForward("admin_atricle_leaves");
  57. }
  58. }