⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 leaveaction.java

📁 本文论述了一个前台笔记本销售系统的开发过程
💻 JAVA
字号:
package com.set.system.struts.action;

import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.set.appframe.data.GenericValueObject;
import com.set.appframe.data.SearchResult;
import com.set.appframe.exception.SystemException;
import com.set.appframe.web.MyBaseAction;
import com.set.home.business.ProductMgr;
import com.set.home.model.ProductVO;
import com.set.system.business.LeaveMgr;
import com.set.system.model.AccountVO;
import com.set.system.model.LeaveVO;
import com.set.utils.StringUtils;
import com.set.utils.WebUtils;

public class LeaveAction extends MyBaseAction {

	private static final int INT_PAGESIZE = 10;

	public ActionForward search(ActionMapping mapping, ActionForm form,
			javax.servlet.http.HttpServletRequest request,
			javax.servlet.http.HttpServletResponse response) {
		int totalPage = 0;
		int intPageNo = 1;		
		LeaveVO values = new LeaveVO(WebUtils.convertEnumeration(request, true));	
		int tmpPageNo = 0;
		String searchStr = request.getParameter("SearchFormValues");
		totalPage = StringUtils.toInteger(values.getItemString("ctlTotalPage"),
				0);
		if (tmpPageNo > totalPage) {
			tmpPageNo = totalPage;
		}

		String ActionID = values.getItemString("ACTIONID");
		if (tmpPageNo > 0) {
			intPageNo = tmpPageNo;
		} else {
			intPageNo = WebUtils.getpageNo(request, ActionID, totalPage);
		}

		SearchResult result = null;

		try {
			LeaveMgr manager = (LeaveMgr) getBean("LeaveMgr");

			result = manager.search(values, intPageNo, INT_PAGESIZE);

		} catch (SystemException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}

	
		request.setAttribute("GVOLIST", this.formatDate2(
				result.getResultList(), new String[] { "CREATEDDATE" }));
		int total = result.getCount();
		if (total % INT_PAGESIZE == 0) {
			totalPage = total / INT_PAGESIZE;
		} else {
			totalPage = total / INT_PAGESIZE + 1;

			// 保存总的记录数
		}

		request.setAttribute("TotalRecords", new Integer(total));
		// 保存总页数
		request.setAttribute("TotalPage", new Integer(totalPage));

		// 当前页数
		request.setAttribute("PageNo", new Integer(intPageNo));

		// 分页字符串
		request.setAttribute("PagerString", WebUtils.getPagerString(totalPage,
				intPageNo));

		// 设定formValues,用来初始化前台的查询条件

		request.setAttribute("FormValues", values);

		return mapping.findForward("search");
	}
	public ActionForward create(ActionMapping mapping, ActionForm form,
			javax.servlet.http.HttpServletRequest request,
			javax.servlet.http.HttpServletResponse response) throws SystemException {
		
		LeaveVO vo =new LeaveVO(WebUtils.convertEnumeration(request));
		HttpSession session = request.getSession();
		String rand = (String) session.getAttribute("rand");
		String input = String.valueOf(request.getParameter("VERIFYCODE"));
		if(!input.equals(rand)){
			return mapping .findForward("create");
		}else{
			LeaveMgr mgr= (LeaveMgr)getBean("LeaveMgr");
			mgr.create(vo);		
			return this.search(mapping, form, request, response);
		}
		
	}
	

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -