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

📄 cplistaction.java

📁 这个是完整的wap项目的源码 开发语言 Java 系统架构 Struts + hibernate + spring 数据库 Mysql5.0 应用服务器Tomcat5.0 开发工具 MyEc
💻 JAVA
字号:
package com.longtime.wap.module.cp.web.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.validator.GenericValidator;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.web.struts.DispatchActionSupport;

import com.longtime.wap.common.WapConstant;
import com.longtime.wap.common.web.Page;
import com.longtime.wap.common.web.PageConstant;
import com.longtime.wap.module.cp.service.CpService;
import com.longtime.wap.module.cp.web.form.CpEditForm;

/**
 * 处理列表页请求
 * 
 * @author liuzb
 * @date Nov 19, 2007
 */
public class CpListAction extends DispatchActionSupport {

	private CpService cpService;

	/**
	 * 注入服务对象
	 * 
	 * @param cpService
	 *            服务对象
	 */
	public void setCpService(CpService cpService) {
		this.cpService = cpService;
	}

	/**
	 * 处理列表页请求
	 * 
	 * @param mapping
	 *            ActionMapping对象
	 * @param form
	 *            ActionForm对象
	 * @param request
	 *            HttpServletRequest对象
	 * @param response
	 *            HttpServletResponse对象
	 * @return ActionForward对象
	 * @throws Exception
	 *             异常对象
	 */
	public ActionForward listCp(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		try {
			CpEditForm cpForm = (CpEditForm) form;
			Page page = null;
			String pageNumber = request.getParameter(PageConstant.PARA_PAGE);

			if (GenericValidator.isBlankOrNull(pageNumber)) {
				if (GenericValidator.isBlankOrNull(cpForm.getCurrentPage())) {
					page = new Page(1);
				} else {
					page = new Page(Integer.parseInt(cpForm.getCurrentPage()));
				}
			} else {
				page = new Page(Integer.parseInt(pageNumber));
			}
			List list = cpService.getCpsList(page);
			request.setAttribute("cps", list);
			request.setAttribute(PageConstant.ATTR_PAGE, page);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return mapping.findForward("listCp");
	}

	/**
	 * 处理删除请求
	 * 
	 * @param mapping
	 *            ActionMapping对象
	 * @param form
	 *            ActionForm对象
	 * @param request
	 *            HttpServletRequest对象
	 * @param response
	 *            HttpServletResponse对象
	 * @return ActionForward对象
	 * @throws Exception
	 *             异常对象
	 */
	public ActionForward deleteCps(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		List<String> messages = new ArrayList<String>();
		try {
			String[] cpIds = request.getParameterValues("deleteCpIds");
			this.cpService.deleteCps(cpIds);
			messages.add("信息删除成功!");
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		if (request.getAttribute(WapConstant.WAP_GLOBAL_MESSAGES) != null) {
			request.removeAttribute(WapConstant.WAP_GLOBAL_MESSAGES);
		}
		request.setAttribute(WapConstant.WAP_GLOBAL_MESSAGES, messages);
		return mapping.findForward("cps");
	}
}

⌨️ 快捷键说明

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