useraction.java

来自「SSH的平台搭建」· Java 代码 · 共 52 行

JAVA
52
字号
package com.lovo.zengxy.struts.action;

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

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

import com.lovo.zengxy.base.web.action.BaseAction;
import com.lovo.zengxy.util.BaseDAOException;
import com.lovo.zengxy.util.PageUtil;
import com.lovo.zengxy.web.service.UserService;

public class UserAction extends BaseAction{
	
	
	private UserService userService;

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	
	public ActionForward userShow(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		ActionForward forword = null;
			String Page = request.getParameter("nowPage");
			int nowPage = 1;
			if(Page!=null){
				nowPage = new Integer(Page);
			}
			try {
				request.setAttribute("uList", this.userService.findUserListPage(nowPage, 15));
				int totalCount = this.userService.getUserTotaleCount();
				System.err.println("数据库中的总数据条数"+totalCount);
				PageUtil pageUtil = new PageUtil(nowPage,totalCount,15,"user.do?method=userShow&");
				request.setAttribute("pageInfo", pageUtil.getPageContent());
				forword = mapping.findForward("ok");
			} catch (BaseDAOException e) {
				super.getLog().error("分页错误",e);
				forword = mapping.findForward("cuowu");
				e.printStackTrace();
			}
		return forword;
	}

}

⌨️ 快捷键说明

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