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

📄 gyousyasearchaction.java

📁 用strutshibernate做的项目
💻 JAVA
字号:
//Created by MyEclipse Struts
// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.0.1/xslt/JavaClass.xsl

package com.dut.struts.action;

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.dut.dao.BatchDBConnectionUtil;
import com.dut.logic.db.Gyousya;
import java.sql.ResultSet;
import java.util.ArrayList;
/** 
 * MyEclipse Struts
 * Creation date: 04-12-2006
 * 
 * XDoclet definition:
 * @struts.action path="/gyousyaSearch" name="gyousyaUpdateActionForm" input="/pages/GyousyaInput.jsp" scope="request" validate="true"
 * @struts.action-forward name="ok" path="/pages/GyousyaSearch.jsp"
 */
public class GyousyaSearchAction extends Action {

	// --------------------------------------------------------- Instance Variables

	// --------------------------------------------------------- Methods

	/** 
	 * Method execute
	 * 对"契約業者情報検索結果一覧"页的"前ページへ"链接和"後ページへ "链接进行方法调用,数据处理和转页
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @author 赵倩 04-12-2006
	 */
	public ActionForward execute(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response) {
		//GyousyaUpdateActionForm gyousyaUpdateActionForm = (GyousyaUpdateActionForm) form;
		// TODO Auto-generated method stub
		ActionForward forward=null;
		String mess=null;
		mess=request.getParameter("mess");
		Gyousya aa=new Gyousya();
		int numall=0;
		/**当无检索条件进行查询检索时,得到的要检索的数据总数*/
		numall=aa.NumAll();
		int yeshu=0;
		/**当无检索条件进行查询检索时,得到所查询的数据总数按照10条一页分,分成几个页*/
		if(numall%10==0){
			/**当总数据数的个位为0,或者总数据数为小于等于十时的分页数*/
			yeshu=numall/10;
		}
		else{
			/**当总数据数的个位不为0,总数据数大于十时的分页数*/
			yeshu=(numall/10)+1;
		}
		int gewei=0;
		/**当无检索条件进行查询检索时,得到查询出的总数据数的个位数*/
		gewei=(numall%10);
		ArrayList list=new ArrayList();
		int from=0;
		ResultSet rs=null;
		String qiID=null;
		String qiName=null;
		/**在进入此action时先把压在session中的"list"移除,以免在这个action中压"list"时混淆*/
		request.getSession().removeAttribute("list");
		qiID=(String)request.getSession().getAttribute("qiID");
		qiName=(String)request.getSession().getAttribute("qiName");	
		//***************************************************************************************************
		/**以契约业者ID查询时的数据显示,但不分页,因为按此条件查只能查一条信息*/
		if(qiID==null){	
		}
		else{
			rs=aa.Jiansuo(qiID,0);
			/** 把"契約業者情報検索結果一覧"中的第一条信息对应在结果集中的位置压在request里*/
			request.setAttribute("where","1");
			/** 把"契約業者情報検索結果一覧"中的最后一条信息对应在结果集中的位置压在request里*/
			request.setAttribute("to","1");
		}
		//********************************************************************************************************
		/**以契约业者NAEM查询时的数据查询,显示,分页*/
		if(qiName==null){			
		}
		else{
			rs=aa.Jiansuo(qiName,1);
			numall=aa.getRows(rs);
			/**以契约业者NAEM查询时,得到所查询的数据总数按照10条一页分,分成几个页*/
			if(numall%10==0){
				/**当总数据数的个位为0,或者总数据数为小于等于十时的分页数*/
				yeshu=numall/10;
			}
			else{
				/**当总数据数的个位不为0,总数据数大于十时的分页数*/
				yeshu=(numall/10)+1;
			}
			/**以契约业者NAEM查询时,得到查询出的总数据数的个位数*/
			gewei=(numall%10);
			
			if(numall<=10){
				rs=aa.selectMess(qiName,1,0,numall);
				request.setAttribute("where",Integer.toString(1));
				request.setAttribute("to",Integer.toString(numall));
				request.getSession().setAttribute("from","1");
			}
			/**以契约业者NAEM查询时,查询的数据总数大于10时*/
			else{
				/**得到当前所在页*/
				from=Integer.parseInt((String)request.getSession().getAttribute("from"));
				/**当按下"契約業者情報検索結果一覧"的"前ページへ"链接时数据查询,显示,分页等*/
				if(mess.equals("qian")){
					/**当当前页为第一页或第二页,点击按钮后上一页显示的是总数据的前10条数据*/
					if(from==1||from==2){
						/**转向"GyousyaSearchDispatchAction,指向分页中的第一页"*/
						ActionForward forward1=mapping.findForward("first");
						forward=forward1;
					}
					/**当当前页不是分页中的第一页或第二页,点击按钮后上一页显示的是此页第一个数据之前的10条数据*/
					else{
						/**以契约业者NAEM查询,得到此页第一个数据之前的10条数据*/
						rs=aa.selectMess(qiName,1,(from-2)*10,10);
						/** 把下一页显示的第一条信息对应在结果集中的位置压在request里*/
						request.setAttribute("where",Integer.toString((from-2)*10+1));
						/** 把下一页显示的最后一条信息对应在结果集中的位置压在request里*/
						request.setAttribute("to",Integer.toString((from-2)*10+10));
						String str_from=Integer.toString(from-1);
						/**把下一页在分页中对应的第几页存在session中*/
						request.getSession().setAttribute("from",str_from);
					}
				}
				/**当按下"契約業者情報検索結果一覧"的"後ページへ "链接时数据查询,显示,分页等*/
				else if(mess.equals("hou")){
					/**当当前页为倒数第一页或第二页,点击按钮后下一页显示的是总数据的最后"gewei"条数据*/
					if(from==yeshu||from==(yeshu-1)){
						/**当以契约业者NAEM查询时,查出的总数据个位数为0时*/
						if(gewei==0){
							/**因为,查出的总数据个位数为0,所以最后一页查询显示的也是10条数据*/
							rs=aa.selectMess(qiName,1,(numall-10),10);
							/** 把下一页显示的第一条信息对应在结果集中的位置压在request里*/
							request.setAttribute("where",Integer.toString((numall-10)+1));
							/** 把下一页显示的最后一条信息对应在结果集中的位置压在request里*/
							request.setAttribute("to",Integer.toString((numall-10)+10));
						}
						/**当以契约业者NAEM查询时,查出的总数据个位数不为0时*/
						else{
							/**最后一页查询显示的是总数据的最后"gewei"条数据*/
							rs=aa.selectMess(qiName,1,(numall-gewei),gewei);
							/** 把下一页显示的第一条信息对应在结果集中的位置压在request里*/
							request.setAttribute("where",Integer.toString((numall-gewei)+1));
							/** 把下一页显示的最后一条信息对应在结果集中的位置压在request里*/
							request.setAttribute("to",Integer.toString((numall-gewei)+gewei));
						}
				        
						/**把下一页在分页中对应的页数压进session中*/
						if(from==yeshu){
							String str_from=Integer.toString(from);
							request.getSession().setAttribute("from",str_from);
						}
						else{
							String str_from=Integer.toString(from+1);
							request.getSession().setAttribute("from",str_from);
						}
					}
					/**当当前页在分页中除倒数第一页或倒数第二页时*/
					else{
						/**以契约业者NAEM查询,得到此页最后一个数据之后的10条数据*/
						rs=aa.selectMess(qiName,1,from*10,10);
						/** 把下一页显示的第一条信息对应在结果集中的位置压在request里*/
						request.setAttribute("where",Integer.toString((from*10)+1));
						/** 把下一页显示的最后一条信息对应在结果集中的位置压在request里*/
						request.setAttribute("to",Integer.toString((from*10)+10));
						/**把下一页在分页中对应的页数压进session中*/
						String str_from=Integer.toString(from+1);
						request.getSession().setAttribute("from",str_from);
					}
				}else{
					rs=aa.selectMess(qiName,1,0,10);
					request.setAttribute("where",Integer.toString(1));
					request.setAttribute("to",Integer.toString(10));
					request.getSession().setAttribute("from","1");
				}
			}
		}
		//********************************************************************************************************
		/**当无检索条件进行检索时,对数据的查询,显示,分页,跟上面的"以契约业者NAEM查询时对数据的查询,显示,分页"步骤大致相同,这里不做过多解释,看会"以契约业者NAEM查询时对数据的查询,显示,分页"就能看会这个*/
		if(qiID==null&&qiName==null){
			if(numall<=10){
				rs=aa.selectMess(null,2,0,numall);
				request.setAttribute("where",Integer.toString(1));
				request.setAttribute("to",Integer.toString(numall));
			}
			else{
				from=Integer.parseInt((String)request.getSession().getAttribute("from"));
				request.getSession().removeAttribute("from");
				request.getSession().removeAttribute("qiID");
				request.getSession().removeAttribute("qiName");
				if(mess==null||mess.equals("")){
					rs=aa.selectMess(null,2,0,10);
					request.setAttribute("where",Integer.toString(1));
					request.setAttribute("to",Integer.toString(10));
					request.getSession().setAttribute("from","1");
				}else if(mess.equals("qian")){
					if(from==1||from==2){
						ActionForward forward1=mapping.findForward("first");
						forward=forward1;
					}
					else{
						rs=aa.selectMess(null,2,(from-2)*10,10);
						request.setAttribute("where",Integer.toString((from-2)*10+1));
						request.setAttribute("to",Integer.toString((from-2)*10+10));
						String str_from=Integer.toString(from-1);
						request.getSession().setAttribute("from",str_from);
					}
				}else if(mess.equals("hou")){
					if(from==yeshu||from==(yeshu-1)){
						if(gewei==0){
							rs=aa.selectMess(null,2,(numall-10),10);
							request.setAttribute("where",Integer.toString((numall-10)+1));
							request.setAttribute("to",Integer.toString((numall-10)+10));
						}
						else{
							rs=aa.selectMess(null,2,(numall-gewei),gewei);
							request.setAttribute("where",Integer.toString((numall-gewei)+1));
							request.setAttribute("to",Integer.toString((numall-gewei)+gewei));
						}
						if(from==yeshu){
							String str_from=Integer.toString(from);
							request.getSession().setAttribute("from",str_from);
						}
						else{
							String str_from=Integer.toString(from+1);
							request.getSession().setAttribute("from",str_from);
						}
					}
					else{
						rs=aa.selectMess(null,2,from*10,10);
						request.setAttribute("where",Integer.toString(from*10+1));
						request.setAttribute("to",Integer.toString((from*10)+10));
						String str_from=Integer.toString(from+1);
						request.getSession().setAttribute("from",str_from);
					}
				}
			}
		}
		/**把最终查询出的结果集处理成ArrayList,压入session,在JSP页面进行循环输出*/
		if(rs==null){
		}
		else{
			/**把最终查询出的结果集处理成ArrayList*/
			list=aa.Messlist(rs);
			/**把ArrayList压入session,为在JSP页面进行循环输出*/
			request.getSession().setAttribute("list",list);
			/**转页,转向"契約業者情報検索結果一覧"页*/
			ActionForward forward2=mapping.findForward("next");
			forward=forward2;
		}
		return forward;
	}

}

⌨️ 快捷键说明

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