📄 customerlistaction.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -