customerlistaction.java

来自「struts+Spring+Hibernate经典入门源码」· Java 代码 · 共 49 行

JAVA
49
字号
package com.softeem.customer.action;

import java.util.List;

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

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

import com.softeem.customer.model.CustomerDAO;
import com.softeem.customer.service.CustomerService;
import com.softeem.util.MyPages;

public class CustomerListAction extends Action {
	private CustomerService customerService;
	
	

	public void setCustomerService(CustomerService customerService) {
		this.customerService = customerService;
	}


	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		String forward = "infos";
		String hql = "from Customers";
		String countHQL = "select count(*) from Customers";
		String strPage = request.getParameter("pageNum");
		int currPage = 1;
		if(strPage!=null)
		{
			currPage = Integer.parseInt(strPage);
		}
		List list = customerService.findAll(hql,currPage,3);
		int recordsNum = customerService.getRecordsNum( countHQL);
		MyPages pages = new MyPages(list,"customerList.do",3,recordsNum,currPage);
		request.setAttribute("infos", pages);
		return mapping.findForward(forward);
	}

	
}

⌨️ 快捷键说明

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