LeaveAction.java
上传用户:yunfeng252
上传日期:2022-07-23
资源大小:12403k
文件大小:3k
- package org.yufeng.struts.action;
- import java.util.List;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
- import org.apache.struts.action.ActionForm;
- import org.apache.struts.action.ActionForward;
- import org.apache.struts.action.ActionMapping;
- import org.yufeng.domains.Leaves;
- import org.yufeng.service.ILeavesServiceDao;
- import org.yufeng.utils.PageService;
- import org.yufeng.utils.Tools;
- public class LeaveAction extends BaseAction {
- Leaves leaves = new Leaves();
- Tools tool = new Tools();
-
- public ActionForward add(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- HttpSession session = request.getSession();
- ILeavesServiceDao leavesService = (ILeavesServiceDao) this
- .getleavesService();
-
- leaves.setLe_names(request.getParameter("le_names"));
- leaves.setLe_qq(request.getParameter("le_qq"));
- leaves.setLe_email(request.getParameter("le_email"));
- leaves.setLe_content(request.getParameter("le_content"));
- leaves.setLe_puttime(tool.getData());
- leaves.setLe_ip(request.getRemoteAddr());
- leavesService.addLeaves(leaves);
- session.setAttribute("message","留言反馈成功!");
-
- return mapping.findForward("article_leaves");
- }
- public ActionForward select(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- ILeavesServiceDao leavesService = (ILeavesServiceDao) this
- .getleavesService();
- HttpSession session = request.getSession();
- List alllist = leavesService.browseALeaves();
- PageService page = new PageService();
- //设置请求分页号
- String pageId = request.getParameter("pageId");
- List leaves = page.getPage(pageId,5,alllist);
- String footer = page.getPageFooter(request.getRequestURI(), "select");
- session.setAttribute("footer", footer);
- request.getSession().setAttribute("leaves", leaves);
- return mapping.findForward("admin_atricle_leave");
- }
- public ActionForward delete(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- ILeavesServiceDao leavesService = (ILeavesServiceDao) this
- .getleavesService();
- String[] ids = request.getParameterValues("le_id");
- for (int i = 0; i < ids.length; i++) {
- leaves.setLe_id(new Integer(ids[i]));
- leavesService.delLeaves(leaves);
- this.select(mapping, form, request, response);
- }
- return mapping.findForward("admin_atricle_leaves");
- }
- }