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

📄 baseaction.java

📁 一种快速开发的Java Web架构,doc里有详细的设计文档和开发文档。
💻 JAVA
字号:
package com.hisoft.cottonbusiness.core.action;

import java.util.HashMap;
import java.util.Map;

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

import org.apache.log4j.Logger;


import com.hisoft.cottonbusiness.core.common.ListWrapper;
import com.hisoft.cottonbusiness.core.common.PageInfo;
import com.hisoft.cottonbusiness.core.common.ServiceLocator;
import com.hisoft.cottonbusiness.core.util.RequestParamUtil;
import com.opensymphony.webwork.ServletActionContext;
import com.opensymphony.webwork.dispatcher.DefaultActionSupport;
import com.opensymphony.xwork.Preparable;

public class BaseAction extends DefaultActionSupport implements Preparable
{
	private static final Logger log = Logger.getLogger(BaseAction.class);

	protected HttpServletRequest request;
	protected HttpServletResponse response;
	protected HttpSession session;
	
	protected Map mapIn = new HashMap();
	protected Map mapOut = new HashMap();
	protected ListWrapper listOut = new ListWrapper();
	
	//分页信息
	private int currPage;
	private int pageSize;
	protected String uri;
	
	//计算出的分页信息
	private int begin;
	private int end;
	
	protected String echoInfo = null;
	
	public void prepare() throws Exception
	{
		log.debug("现在开始初始化:");
		request = ServletActionContext.getRequest();
		response = ServletActionContext.getResponse();
		session = request.getSession();
		session.setAttribute("echo_info",echoInfo);
	}



	public ListWrapper getListOut()
	{
		return listOut;
	}



	public void setListOut(ListWrapper listOut)
	{
		this.listOut = listOut;
	}



	public Map getMapIn()
	{
		return mapIn;
	}

	public void setMapIn(Map mapIn)
	{
		this.mapIn = mapIn;
	}

	public Map getMapOut()
	{
		return mapOut;
	}

	public void setMapOut(Map mapOut)
	{
		this.mapOut = mapOut;
	}



	public String getEchoInfo()
	{
		return echoInfo;
	}

	public void setPageInfo(PageInfo pageInfo)
	{
		request.setAttribute("pageInfo",pageInfo);
	}

	protected String generateURI()
	{
		return "" ;
	}

	public int getRecordBegin()
	{
		begin = (getCurrPage() - 1) * getPageSize() + 1;
		
		return begin;
	}
	
	public int getRecordEnd()
	{
		end = getRecordBegin() + getPageSize() - 1;
		
		return end;
	}

	public int getCurrPage()
	{
		currPage = RequestParamUtil.getInt(request,"currPage",1);
		return currPage;
	}

	public int getPageSize()
	{
		pageSize = RequestParamUtil.getInt(request,"pageSize",10);
		return pageSize;
	}

	

}

⌨️ 快捷键说明

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