| 導購 | 订阅 | 在线投稿
分享
 
 
 

表單查詢顯示翻頁等不可用,提示對象不支持此屬性或方法,切記查詢按鈕的name值不能爲submit

2007-03-16 11:15:36  編輯來源:互聯網  简体版  手機版  評論  字體: ||
 
  切記查詢按鈕的name值不能爲submit。其中原代碼如下:
  <input name="submit" type="submit" class="button" style="WIDTH: 80px" value="查詢">
  我們應當改爲:
  <input name="submit1" type="submit" class="button" style="WIDTH: 80px" value="查詢">,不然會出現表單查詢顯示是點下一步,將繼續向下一頁翻頁,但是點上一頁,下一頁,等都不可用。
  原代碼如下:
  <%@ page contentType="text/html; charset=gbk" language="java" import="java.sql.*" errorPage="" %>
  <%@ page import ="pub.*" %>
  <%@ page import="leader.*"%>
  <%
   int x=Check.CheckPage(request,"leader_employee_search");
   String userid=(String)session.getAttribute("userid");
   LeaderBean leader=new LeaderBean();
   String Error="";
   if (x==1){
   Error="<script>alert('你已掉線,需要重新登陸!');top.location.href='../login.jsp'</script>";
   }else{
   if (x==2){
   Error="<script>alert('你無權進入該頁面!');history.back();</script>";
   }
   if(leader.checkCompetenceCorp(userid)==0){
   Error="<script>alert('你無權進入該頁面!');history.back();</script>";
   }
   }
  %>
  <%=Error%>
  <%
   if (x!=0){
   return;
   }
  %>
  <html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=gbk">
  <title>查詢其管屬員工信息</title>
  <link href="../css/putong.css" type="text/css" rel="stylesheet">
  <script>
   var req;
   var number='all'; //外,下拉框可顯示全部部門&處
   window.onload=function()
   {
  
   }
   function Change_Select(flag)
   {
   var flag1=flag;//是爲了解決onchange()後值要改變&onload()(查詢提交)後值要保存的問題
   //alert(flag1);
   var zhi = document.getElementById('Corp').value;
   var hidden_depart=document.all.HiddenKeyDepart.value;
   var hidden_UserID=document.all.HiddenUserId.value;
   var url = "../selectCropDepartLeader?state="+number+"&keyDepart="+hidden_depart+"&id=" + escape(zhi)+"&flag="+flag1+"&leaderid="+hidden_UserID;
   //alert(url);
   if (window.XMLHttpRequest) {
   req = new XMLHttpRequest();
   }else if (window.ActiveXObject) {
   req = new ActiveXObject("Microsoft.XMLHTTP");
   }
  
  
   if(req){
   req.open("GET", url, true);
   req.onreadystatechange = callback;
  
   req.send(null);
   }
   }
  
   function callback() {
  
   if (req.readyState == 4) {
   if (req.status == 200) {
   parseMessage();
   // update the HTML DOM based on whether or not message is valid
   }else{
   alert ("Not able to retrieve description" +req.status+req.statusText);
   }
   }
   }
  
   function parseMessage() {
  
   var xmlDoc = req.responseXML.documentElement;
   var xSel = xmlDoc.getElementsByTagName('select');
   var select_root = document.getElementById('Depart');
   select_root.options.length=0;
   for(var i=0;i<xSel.length;i++)
   {
   var xValue = xSel[i].childNodes[0].firstChild.nodeValue;
   var xText = xSel[i].childNodes[1].firstChild.nodeValue;
   var option = new Option(xText,xValue);
  
   try
   {
   select_root.add(option);
   }
   catch(e)
   {
  
   }
  
   }
   }
  
  function chan(){
   document.formlist.submit();
  }
  </script>
  </head>
  <body onload="Change_Select(1)">
  <%
   String strCorp=request.getParameter("Corp");
   String strDepart=request.getParameter("Depart");
   //String strPositionName=request.getParameter("PositionName") ;
   //String strLeaderName=request.getParameter("LeaderName");
   if(strCorp==null) strCorp="";
   if(strDepart==null) strDepart="";
   //if(strChu==null) strChu="";
   //if(strPositionName == null) strPositionName="0";
   //if(strLeaderName==null) strLeaderName="";
   String strCropID1=(String)session.getAttribute("cropid");
   //判斷如果登陸員工是總公司之外的就只顯示此員工所在的公司
   //if(strCropID1.equals("1")==false) strCorp=strCropID1;
   Conn conn=new Conn();
   DataTable dtChuName=new DataTable();
   //String SqlChuName="";
  
  %>
  <form name="formlist" method="get" action="leader_employee_search.jsp">
  <input type="hidden" name="hiddensql">
  <table cellSpacing="0" cellPadding="0" width="100%" bgColor="#bfcae6" border="0" background="../images/subtitle.gif">
   <tr>
   <td width="100%" height="26"><FONT face="宋體">
   <DIV align="left"><FONT face="宋體" color="#ffffff">&nbsp;&nbsp;當前位置:領導查詢&gt;&gt;查詢其管屬員工信息 </FONT>
   </DIV>
   </FONT>
   </td>
   </tr>
   </table>
   <table border="0" cellpadding="0" cellspacing="0" width="100%" background="../images/ico_14.jpg">
   <tr>
   <td height="26" align="left" nowrap>&nbsp;</td>
   <td width="40" align="right" nowrap>公司:</td>
   <td width="100" align="left"><select name="Corp" id="Corp" style="WIDTH: 100px" onChange="Change_Select(0)" ></select> </td>
   <td width="40" align="right" nowrap>部門:</td>
   <td width="100" align="left">
   <select name="Depart" id="Depart" style="WIDTH: 100px"></select> </td>
   <td width="40" align="left" >
  
   類型: </td>
   <td width="80" align="left" ><select name="userstate" onChange="chan();" style="WIDTH: 80px">
   <option value="0">在職人員</option>
   <option value="1">離職人員</option>
   </select></td>
   <td width="90" align="right" ><input name="submit1" type="submit" class="button" style="WIDTH: 80px" value="查詢"></td>
   <td width="90" align="right" ><input name="button1" type="button" class="button" style="WIDTH: 80px" onClick="javascript:window.print();" value="打印"></td>
   <td width="10" align="left" >&nbsp;</td>
   </tr>
   </table>
   <%
  
  
   DataGrid dg=new DataGrid("1",request,"formlist",15,"");
   DataGridColumnItem dgci=new DataGridColumnItem();
   dgci.ColType=ColumnItemType.BindDataColumn;
   dgci.HeadText="人員編號";
   dgci.BindField="UserCode";
   dgci.Width="10%";
   dg.addColumn(dgci);
  
   dgci=new DataGridColumnItem();
   dgci.ColType=ColumnItemType.BindDataColumn;
   dgci.HeadText="人員姓名";
   dgci.BindField="UserName";
   dgci.Width="15%";
   dg.addColumn(dgci);
  
   dgci=new DataGridColumnItem();
   dgci.ColType=ColumnItemType.BindDataColumn;
   dgci.HeadText="公司";
   dgci.BindField="CropName";
   dgci.Width="10%";
   dg.addColumn(dgci);
  
   dgci=new DataGridColumnItem();
   dgci.ColType=ColumnItemType.BindDataColumn;
   dgci.HeadText="部門";
   dgci.BindField="DepartName";
   dgci.Width="15%";
   dg.addColumn(dgci);
  
   dgci=new DataGridColumnItem();
   dgci.ColType=ColumnItemType.BindDataColumn;
   dgci.HeadText="性別";
   dgci.BindField="Sex";
   dgci.Width="10%";
   dg.addColumn(dgci);
  
   dgci=new DataGridColumnItem();
   dgci.ColType=ColumnItemType.BindDataColumn;
   dgci.HeadText="職務";
   dgci.BindField="RankName";
   dgci.Width="20%";
   dg.addColumn(dgci);
  
   dgci=new DataGridColumnItem();
   dgci.ColType=ColumnItemType.LinkButtonColumn;
   //dgci.HeadText="編輯";
   dgci.BindField="詳細信息";
   dgci.Script="../employee/employee_all_info_detail.jsp?Key=[UserID]";
   dgci.Width="20%";
   dg.addColumn(dgci);
  
   String cropid=(String)session.getAttribute("cropid");
   String roleid=(String)session.getAttribute("roleid");
  
  
  
   //System.out.println("userid:"+userid);
   String Sql="";
   //int a[]=new int[20];
   String strCropID[]=new String[100];
   String strDepartID[]=new String[100];
  
   DataTable dt =new DataTable();
   //String departid=(String)session.getAttribute("departid");
   String mSql_competence="Select CropID,DepartID from leadquery02_competence c where c.UserID="+userid+" ";
   //System.out.println("testme");
   //System.out.println("mSql_competence:"+mSql_competence);
   Sql="select DISTINCT a.UserID,UserCode,UserName,b.sex,";
   Sql+=" CropName=(Select MachName from sys04_Machine c where a.CropID=c.MachID),";
   Sql+=" DepartName=(select MachName from sys04_Machine d where a.DepartID=d.MachID ),";
   Sql+=" RankName=(select RankName from Basic02_Rank where Rankid=rank)";
   //Sql+=" from employee01_Basic a , employee02_info b ";
   //Sql+=" where a.UserID=b.UserID ";
   Sql+=" FROM employee01_Basic a LEFT OUTER JOIN employee02_info b ON a.UserID = b.UserID ";
   if(conn.querySql(mSql_competence,dt)){
   if(dt.getRowCount()>0){
   Sql+=" Where ( ";
   for(int i=0;i<dt.getRowCount();i++){
   strCropID[i] = dt.getItemForName(i,"CropID");
   strDepartID[i] = dt.getItemForName(i,"DepartID");
   //System.out.println("strCropID:"+strCropID[i]);
   //System.out.println("strDepartID:"+strDepartID[i]);
   if(i>0 ){
   Sql+=" OR ";
   }
   if(strDepartID[i] != null && strDepartID[i].equals("")==false ){
   Sql+=" ( a.CropID="+strCropID[i]+" ";
   Sql+=" AND a.DepartID="+strDepartID[i]+" )";
   }
   else{
   Sql+=" ( a.CropID="+strCropID[i]+" )";
   }
   }
   Sql+=" ) ";
   //System.out.println("Sqlleader1:"+Sql);
   }
   }
   //System.out.println("Sqlleader:"+Sql);
   String userstate=request.getParameter("userstate");
   if (userstate!=null){
   Sql+=" AND a.UserState='"+userstate+"' ";
   out.println("<script>document.all.userstate.value='"+userstate+"';</script>");
   }else{
   Sql+=" AND a.UserState='0' ";
   }
   String hiddensql=request.getParameter("hiddensql");
   if (hiddensql!=null && hiddensql.length()>0){
   Sql+=" and "+hiddensql;
  
   out.println("<script>document.all.hiddensql.value='"+hiddensql+"';</script>");
   }
   if(strCorp.length()>0)
   Sql+=" AND a.CropID = "+PubClass.getString(strCorp)+" ";
   if (strDepart.length()>0 && strDepart.equals("Pselect")==false )
   Sql+= " AND a.DepartID = "+PubClass.getString(strDepart)+" ";
   System.out.println("Sql:"+Sql);
   if (conn.execSql(Sql)){
   }
   else{
   response.setCharacterEncoding("GBK");
   String LastOperMsg="不能讀取權限數據!";
   out.println("<script>alert('"+LastOperMsg+"');window.returnValue=0;window.close();</script>");
   }
   dg.bindSql(Sql);
   out.print(dg.ShowGrid());
   %>
   <%
   String m1Script="";
   m1Script=PubClass.BindAllCorp_Leader_List("document.all.Corp",userid);
   //m1Script=PubClass.BindAllCorpList2("document.all.Corp");
   %>
   <%= m1Script%>
   <%
   String sLeaderList="";
   //System.out.println("strDepart2:"+PubClass.getString(strDepart));
   sLeaderList+="<script>document.all.Corp.value='"+PubClass.getString(strCorp)+"';</script>";
   sLeaderList+="<script>document.all.Depart.value='"+PubClass.getString(strDepart)+"';</script>";
  %>
  <%=sLeaderList%>
   <input type="hidden" name="HiddenKeyDepart" value="<%=strDepart%>" >
   <input type="hidden" name="HiddenUserId" value="<%=userid%>" >
  </form>
  </body>
  </html>
  頁面錯誤如圖所示:
  注意這裏的錯誤和order by的提示是一樣的,但問題不一樣。
  爲了解決這個問題:
  我們首先跟蹤程序:dg.ShowGrid():
  發現要執行:String num=conn.lookupfirst("select count(*) as cnum from ("+mSql+") as awqertc1q ","cnum");
  我們將上面打印的sql語句帶入這裏:
  SQl:select DISTINCT a.UserID,UserCode,UserName,b.sex, CropName=(Select MachName from sys04_Machine c where a.CropID=c.MachID), DepartName=(select MachName from sys04_Machine d where a.DepartID=d.MachID ), RankName=(select RankName from Basic02_Rank where Rankid=rank) FROM employee01_Basic a LEFT OUTER JOIN employee02_info b ON a.UserID = b.UserID Where ( ( a.CropID=1 ) OR ( a.CropID=202 AND a.DepartID=207 ) OR ( a.CropID=1 ) OR ( a.CropID=1 ) OR ( a.CropID=202 ) OR ( a.CropID=253 ) OR ( a.CropID=202 AND a.DepartID=207 ) OR ( a.CropID=202 AND a.DepartID=207 ) OR ( a.CropID=202 AND a.DepartID=209 ) OR ( a.CropID=202 ) OR ( a.CropID=204 ) OR ( a.CropID=204 ) ) AND a.UserState='0'
  我們將它在sqlserver中執行,發現沒有問題:
  我們再將它傳入到上面的lookupfirst函數當中,mSql爲上面打印的sql語句:
  select count(*) as cnum from ("+mSql+") as awqertc1q
  結果顯示沒有問題(注意的是如果帶入排序,就會出現問題,這個問題比較深奧,我們以後再說。)
  那麽這是什麽問題呢?難道真的是和排序一樣出現的實現小數據量和海量數據的通用分頁顯示存儲過程出現的問題一樣嗎?于是我也仿照對排序的解決方法一樣,在select前加入top 100 percent 但是卻不能顯示!!!! 如此難道這又是實現小數據量和海量數據的通用分頁顯示存儲過程出現的問題,而且是不同形式,連top 100 percen都不能用?我們再繼續跟蹤代碼,看看基礎代碼是怎麽實現的,如果要改動基礎代碼,將對整個系統産生巨大的影響。但出現問題我們必須解決,只好硬著頭皮看下去,爲了,跟蹤系統代碼:
   public String ShowGrid(){
   try{
   String Table="";
   Conn conn=new Conn();
   String num=conn.lookupfirst("select count(*) as cnum from ("+mSql+") as awqertc1q ","cnum");
   if (num.trim().length()<1) num="0";
   int CountNum=Integer.parseInt(num);
   int CurrentNum=1;
   if (mRequest.getParameter(getHiddenContolID())!=null){
   String m=mRequest.getParameter(getHiddenContolID());
   if (m.trim().length()<1) m="0";
   CurrentNum=Integer.parseInt(m);
   }
   //if (mRequest.getParameter(getChangePageContolID())!=null){
   // String m=mRequest.getParameter(getChangePageContolID());
   // if (m.trim().equals("0")){
   // CurrentNum=1;
   // }
   //}
   //Table+="select count(*) as cnum from ("+mSql+") as a ";
   int Pagecount= (CountNum+mRowInPage-1)/mRowInPage;
   Table+=getGridJavascriptFun(CurrentNum,CountNum,Pagecount);
   Table+=getGridTable(CurrentNum,CountNum,Pagecount);
   //System.out.println("Table:"+Table);
   return Table;
   }catch(Exception e){
   return e.getMessage();
   }
   }
  我們將Table 打印出來:
  <script>
  function LastPage1Fun()
  {
  document.all.datagrid1_pageno.value='31';
  document.all.datagrid1_changepage.value='1';
  window.document.formlist.submit();
  }
  function JumpPage1Fun(){
  document.all.datagrid1_pageno.value=document.all.datagrid1_ump.value;
  document.all.datagrid1_changepage.value='1';
  window.document.formlist.submit();
  }
  function NextPage1Fun()
  {
  document.all.datagrid1_pageno.value='2';
  document.all.datagrid1_changepage.value='1';
  window.document.formlist.submit();
  }
  function prePage1Fun()
  {
  document.all.datagrid1_pageno.value='1';
  document.all.datagrid1_changepage.value='1';
  window.document.formlist.submit();
  }
  function FirstPage1Fun()
  {
  document.all.datagrid1_pageno.value='1';
  document.all.datagrid1_changepage.value='1';
  window.document.formlist.submit();
  }
  function page1chk(id,trueOrFalse){
  if(trueOrFalse==null) trueOrFalse=true;
  var chks=document.getElementsByName(id);
  for (var i=0;i<chks.length;i++)
   chks[i].checked=trueOrFalse;
  page1chkdata(id);
   }
  function page1chkdata(id){
   document.all.datagrid1_checkvalue.value='';
  var chks=document.getElementsByName(id);
  for (var i=0;i<chks.length;i++){
   if (chks[i].checked){
   document.all.datagrid1_checkvalue.value+=chks[i].value+',';
   }
   }
   var a=document.all.datagrid1_checkvalue.value.length ;
   if (a>0){
   document.all.datagrid1_checkvalue.value=document.all.datagrid1_checkvalue.value.substr(0,a-1);
   }
  }</script>
  <body>
  <form>
  <input type='Hidden' Name='datagrid1_pageno' value='1'>
  <input type='Hidden' Name='datagrid1_changepage' value='0'>
  <table cellspacing='0' cellpadding='2' rules='all' TableBackColor='#DBDBDB' TablelineColor='#000000' TableWidth='100%' TableCellpadding='3' IsPicbutton='False' TitleColor='#000000' IsShowDelChk='True' PageNO='1' TableColor='#000000' Insert_ShowScroll='False' AllPage='1' bordercolor='#124D70' border='1' id='WGrid1' style='border-color:#124D70;width:100%;border-collapse:collapse;'>
  <tr class='ListTableHeader' align='Center' style='color:Black;background-color:#E7EFFF;'>
  <td style='width:10%;'>人員編號</td>
  <td style='width:15%;'>人員姓名</td>
  <td style='width:10%;'>公司</td>
  <td style='width:15%;'>部門</td>
  <td style='width:10%;'>性別</td>
  <td style='width:20%;'>職務</td>
  <td style='width:20%;'></td>
  </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'">
  <td Align='center'>000001</td>
  <td Align='center'>唐運祥</td>
  <td Align='center'>總公司</td>
  <td Align='center'>公司領導</td>
  <td Align='center'>男</td>
  <td Align='center'></td>
  <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=1">詳細信息</a></td>
  </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'">
  <td Align='center'>000002</td>
  <td Align='center'>傅助</td>
  <td Align='center'>總公司</td>
  <td Align='center'>公司領導</td>
  <td Align='center'>男</td>
  <td Align='center'></td>
  <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=2">詳細信息</a></td>
  </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'">
  <td Align='center'>000003</td>
  <td Align='center'>宋福興</td>
  <td Align='center'>總公司</td>
  <td Align='center'>公司領導</td>
  <td Align='center'>男</td>
  <td Align='center'></td>
  <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=3">詳細信息</a></td>
  </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'">
  <td Align='center'>000005</td>
  <td Align='center'>傅安平</td>
  <td Align='center'>總公司</td>
  <td Align='center'>公司領導</td>
  <td Align='center'>男</td>
  <td Align='center'></td>
  <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=4">詳細信息</a></td>
  </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'">
  <td Align='center'>000006</td>
  <td Align='center'>松下敏彥</td>
  <td Align='center'>總公司</td>
  <td Align='center'>公司領導</td>
  <td Align='center'>男</td>
  <td Align='center'></td>
  <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=5">詳細信息</a></td>
  </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'">
  <td Align='center'>000018</td>
  <td Align='center'>張海山</td>
  <td Align='center'>總公司</td>
  <td Align='center'>公司領導</td>
  <td Align='center'>男</td>
  <td Align='center'></td>
  <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=6">詳細信息</a></td>
  </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'">
  <td Align='center'>000019</td>
  <td Align='center'>王夢飛</td>
  <td Align='center'>總公司</td>
  <td Align='center'>辦公室</td>
  <td Align='center'>女</td>
  <td Align='center'></td>
  <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=7">詳細信息</a></td>
  </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'">
  <td Align='center'>000020</td>
  <td Align='center'>吳劍</td>
  <td Align='center'>總公司</td>
  <td Align='center'>辦公室</td>
  <td Align='center'>男</td>
  <td Align='center'></td>
  <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=8">詳細信息</a></td>
  </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'">
  <td Align='center'>000021</td>
  <td Align='center'>徐喆</td>
  <td Align='center'>總公司</td>
  <td Align='center'>辦公室</td>
  <td Align='center'>男</td>
  <td Align='center'></td>
  <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=9">詳細信息</a></td>
  </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'">
  <td Align='center'>000022</td>
  <td Align='center'>田靓</td>
  <td Align='center'>總公司</td>
  <td Align='center'>辦公室</td>
  <td Align='center'>男</td>
  <td Align='center'></td>
  <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=10">詳細信息</a></td>
  </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'">
  <td Align='center'>000023</td>
  <td Align='center'>劉歆</td>
  <td Align='center'>總公司</td>
  <td Align='center'>辦公室</td>
  <td Align='center'>男</td>
  <td Align='center'></td>
  <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=11">詳細信息</a></td>
  </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'">
  <td Align='center'>000024</td>
  <td Align='center'>巴音</td>
  <td Align='center'>總公司</td>
  <td Align='center'>辦公室</td>
  <td Align='center'>男</td>
  <td Align='center'></td>
  <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=12">詳細信息</a></td>
  </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'">
  <td Align='center'>000025</td>
  <td Align='center'>于勇</td>
  <td Align='center'>總公司</td>
  <td Align='center'>辦公室</td>
  <td Align='center'>男</td>
  <td Align='center'></td>
  <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=13">詳細信息</a></td>
  </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'">
  <td Align='center'>000026</td>
  <td Align='center'>彭曉敏</td>
  <td Align='center'>總公司</td>
  <td Align='center'>辦公室</td>
  <td Align='center'>女</td>
  <td Align='center'></td>
  <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=14">詳細信息</a></td>
  </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'">
  <td Align='center'>000027</td>
  <td Align='center'>楊建靈</td>
  <td Align='center'>總公司</td>
  <td Align='center'>辦公室</td>
  <td Align='center'>男</td>
  <td Align='center'></td>
  <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=15">詳細信息</a></td>
  </tr><tr align="Right" style="color:#000066;background-color:#DFDFDF;">
  <td colspan='7'>
  <table border="0" style="color:#000066;background-color:#DFDFDF;border-width:0px;width:100%;">
  <tr>
  <td align="Left" style="width:15%;">
  <a disabled="disabled" title="首頁" style="font-family:webdings;font-size: 11pt;" onclick="FirstPage1Fun(); ">9</a>
  <font style='font-family:Arial;font-size:9pt'> </font>
  <a disabled="disabled" title="上一頁" style="font-family:webdings;font-size: 11pt;">7</a>
  <font style='font-family:Arial;font-size:9pt'> </font>
  <a style="cursor:hand; color:#0A52CB" title="下一頁" style="font-family:webdings;font-size: 11pt;" onclick="NextPage1Fun();">8</a>
  <font style='font-family:Arial;font-size:9pt'> </font>
  <a title="尾頁" onclick="LastPage1Fun();" style="font-family:webdings;font-size: 11pt; ">:</a>
  </td><td align="Left" style="font-family:宋體;font-size:9pt">
  頁次:<font color="#E23000">
  <input name='datagrid1_ump' class="input" type="text" value="1" maxlength="3" onchange="JumpPage1Fun(); " language="javascript"
  style="border-style:Groove;font-family:宋體;font-size:9pt;height:18px;width:18px;text-align :Center;" /><b>/31</b></font>
  每頁<font color="#E23000"><b>15</b></font>
  條 共有記錄<font color="red"><b>459</b></font>條
  </td>
  </tr>
  </table>
  </td>
  </tr>
  </table>
  然後新建一個頁面:1.jsp
  在dreamver顯示結果如下
  然後我們發現NextPage1Fun()是javscrip腳本,我想會不會是用于我的sql代碼中用了or所以導致NextPage1Fun()值有問題(可能哪個對象在莫中情況下未賦值),或者是我原先說過的小數據量和海量數據的通用分頁顯示存儲過程出現的問題,如此將要更改系統的基礎實現!!!,但是我們必須先將問題縮小到小的範圍內,不能先認定到莫個原因,這時分析程序和事務的關鍵,如此我們才能找到本質原因。
  那麽由于領導權限上面的公司-部門聯動和其他地方不同,是采用不同的算法實現,會不會是它的問題,我于是將 <body onload="Change_Select(1)">中的onload="Change_Select(1)"去掉,以便消除此二級聯動的影響。但然而有問題。會不是是參數當莫個時候取空值造成的影響呢?但是那麽多參數如何確定??
  于是,我就想到了一個簡單辦法,從簡單到複雜一步一步叠代。
  我先將第一頁顯示的sql語句取出,直接顯示,看是後台問題,還是是我原先說過的小數據量和海量數據的通用分頁顯示存儲過程出現的問題,因爲這裏用了OR這個特殊的關鍵字。(排序 需要在select語句前加 top 100 percent)。
  <%@ page contentType="text/html; charset=gbk" language="java" import="java.sql.*" errorPage="" %>
  <%@ page import ="pub.*" %>
  <%@ page import="leader.*"%>
  <html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=gbk">
  </head>
  
   <body>
   <form name="formlist" method="post" action="test.jsp">
   <input name="submit1" type="submit" class="button" style="WIDTH: 80px" value="查詢">
  <%
   DataGrid dg=new DataGrid("1",request,"formlist",15,"");
   DataGridColumnItem dgci=new DataGridColumnItem();
   dgci.ColType=ColumnItemType.BindDataColumn;
   dgci.HeadText="人員編號";
   dgci.BindField="UserCode";
   dgci.Width="10%";
   dg.addColumn(dgci);
  
   dgci=new DataGridColumnItem();
   dgci.ColType=ColumnItemType.BindDataColumn;
   dgci.HeadText="人員姓名";
   dgci.BindField="UserName";
   dgci.Width="15%";
   dg.addColumn(dgci);
  
   dgci=new DataGridColumnItem();
   dgci.ColType=ColumnItemType.BindDataColumn;
   dgci.HeadText="公司";
   dgci.BindField="CropName";
   dgci.Width="10%";
   dg.addColumn(dgci);
  
   dgci=new DataGridColumnItem();
   dgci.ColType=ColumnItemType.BindDataColumn;
   dgci.HeadText="部門";
   dgci.BindField="DepartName";
   dgci.Width="15%";
   dg.addColumn(dgci);
  
   dgci=new DataGridColumnItem();
   dgci.ColType=ColumnItemType.BindDataColumn;
   dgci.HeadText="性別";
   dgci.BindField="Sex";
   dgci.Width="10%";
   dg.addColumn(dgci);
  
   dgci=new DataGridColumnItem();
   dgci.ColType=ColumnItemType.BindDataColumn;
   dgci.HeadText="職務";
   dgci.BindField="RankName";
   dgci.Width="20%";
   dg.addColumn(dgci);
  
   dgci=new DataGridColumnItem();
   dgci.ColType=ColumnItemType.LinkButtonColumn;
   //dgci.HeadText="編輯";
   dgci.BindField="詳細信息";
   dgci.Script="../employee/employee_all_info_detail.jsp?Key=[UserID]";
   dgci.Width="20%";
   dg.addColumn(dgci);
  
   String Sql="";
   Sql="select DISTINCT a.UserID,UserCode,UserName,b.sex, CropName=(Select MachName from sys04_Machine c where a.CropID=c.MachID), DepartName=(select MachName from sys04_Machine d where a.DepartID=d.MachID ), RankName=(select RankName from Basic02_Rank where Rankid=rank) FROM employee01_Basic a LEFT OUTER JOIN employee02_info b ON a.UserID = b.UserID Where ( ( a.CropID=1 ) OR ( a.CropID=202 AND a.DepartID=207 ) OR ( a.CropID=1 ) OR ( a.CropID=1 ) OR ( a.CropID=202 ) OR ( a.CropID=253 ) OR ( a.CropID=202 AND a.DepartID=207 ) OR ( a.CropID=202 AND a.DepartID=207 ) OR ( a.CropID=202 AND a.DepartID=209 ) OR ( a.CropID=202 ) OR ( a.CropID=204 ) OR ( a.CropID=204 ) ) AND a.UserState='0' ";
   dg.bindSql(Sql);
   out.print(dg.ShowGrid());
   %>
   </form>
   </body>
  </html>
  我們第一次沒有加查詢按鈕,發現程序沒問題,但是當加了查詢按鈕之後,竟然出了問題。說明這個查詢有問題!!!我向我們項目經理說明了情況,我以爲後台代碼與這個查詢有沖突,他說他曾經在網上看到了,這個<input name="submit" type="submit" class="button" style="WIDTH: 80px" value="查詢">的名字和type不能一樣!!!
  將它改爲name="submit1",測試,問題解決。真是山窮水複疑無路,柳暗花明又一村
 
切記查詢按鈕的name值不能爲submit。其中原代碼如下: <input name="submit" type="submit" class="button" style="WIDTH: 80px" value="查詢"> 我們應當改爲: <input name="submit1" type="submit" class="button" style="WIDTH: 80px" value="查詢">,不然會出現表單查詢顯示是點下一步,將繼續向下一頁翻頁,但是點上一頁,下一頁,等都不可用。 原代碼如下: <%@ page contentType="text/html; charset=gbk" language="java" import="java.sql.*" errorPage="" %> <%@ page import ="pub.*" %> <%@ page import="leader.*"%> <% int x=Check.CheckPage(request,"leader_employee_search"); String userid=(String)session.getAttribute("userid"); LeaderBean leader=new LeaderBean(); String Error=""; if (x==1){ Error="<script>alert('你已掉線,需要重新登陸!');top.location.href='../login.jsp'</script>"; }else{ if (x==2){ Error="<script>alert('你無權進入該頁面!');history.back();</script>"; } if(leader.checkCompetenceCorp(userid)==0){ Error="<script>alert('你無權進入該頁面!');history.back();</script>"; } } %> <%=Error%> <% if (x!=0){ return; } %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk"> <title>查詢其管屬員工信息</title> <link href="../css/putong.css" type="text/css" rel="stylesheet"> <script> var req; var number='all'; //外,下拉框可顯示全部部門&處 window.onload=function() { } function Change_Select(flag) { var flag1=flag;//是爲了解決onchange()後值要改變&onload()(查詢提交)後值要保存的問題 //alert(flag1); var zhi = document.getElementById('Corp').value; var hidden_depart=document.all.HiddenKeyDepart.value; var hidden_UserID=document.all.HiddenUserId.value; var url = "../selectCropDepartLeader?state="+number+"&keyDepart="+hidden_depart+"&id=" + escape(zhi)+"&flag="+flag1+"&leaderid="+hidden_UserID; //alert(url); if (window.XMLHttpRequest) { req = new XMLHttpRequest(); }else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } if(req){ req.open("GET", url, true); req.onreadystatechange = callback; req.send(null); } } function callback() { if (req.readyState == 4) { if (req.status == 200) { parseMessage(); // update the HTML DOM based on whether or not message is valid }else{ alert ("Not able to retrieve description" +req.status+req.statusText); } } } function parseMessage() { var xmlDoc = req.responseXML.documentElement; var xSel = xmlDoc.getElementsByTagName('select'); var select_root = document.getElementById('Depart'); select_root.options.length=0; for(var i=0;i<xSel.length;i++) { var xValue = xSel[i].childNodes[0].firstChild.nodeValue; var xText = xSel[i].childNodes[1].firstChild.nodeValue; var option = new Option(xText,xValue); try { select_root.add(option); } catch(e) { } } } function chan(){ document.formlist.submit(); } </script> </head> <body onload="Change_Select(1)"> <% String strCorp=request.getParameter("Corp"); String strDepart=request.getParameter("Depart"); //String strPositionName=request.getParameter("PositionName") ; //String strLeaderName=request.getParameter("LeaderName"); if(strCorp==null) strCorp=""; if(strDepart==null) strDepart=""; //if(strChu==null) strChu=""; //if(strPositionName == null) strPositionName="0"; //if(strLeaderName==null) strLeaderName=""; String strCropID1=(String)session.getAttribute("cropid"); //判斷如果登陸員工是總公司之外的就只顯示此員工所在的公司 //if(strCropID1.equals("1")==false) strCorp=strCropID1; Conn conn=new Conn(); DataTable dtChuName=new DataTable(); //String SqlChuName=""; %> <form name="formlist" method="get" action="leader_employee_search.jsp"> <input type="hidden" name="hiddensql"> <table cellSpacing="0" cellPadding="0" width="100%" bgColor="#bfcae6" border="0" background="../images/subtitle.gif"> <tr> <td width="100%" height="26"><FONT face="宋體"> <DIV align="left"><FONT face="宋體" color="#ffffff">&nbsp;&nbsp;當前位置:領導查詢&gt;&gt;查詢其管屬員工信息 </FONT> </DIV> </FONT> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" width="100%" background="../images/ico_14.jpg"> <tr> <td height="26" align="left" nowrap>&nbsp;</td> <td width="40" align="right" nowrap>公司:</td> <td width="100" align="left"><select name="Corp" id="Corp" style="WIDTH: 100px" onChange="Change_Select(0)" ></select> </td> <td width="40" align="right" nowrap>部門:</td> <td width="100" align="left"> <select name="Depart" id="Depart" style="WIDTH: 100px"></select> </td> <td width="40" align="left" > 類型: </td> <td width="80" align="left" ><select name="userstate" onChange="chan();" style="WIDTH: 80px"> <option value="0">在職人員</option> <option value="1">離職人員</option> </select></td> <td width="90" align="right" ><input name="submit1" type="submit" class="button" style="WIDTH: 80px" value="查詢"></td> <td width="90" align="right" ><input name="button1" type="button" class="button" style="WIDTH: 80px" onClick="javascript:window.print();" value="打印"></td> <td width="10" align="left" >&nbsp;</td> </tr> </table> <% DataGrid dg=new DataGrid("1",request,"formlist",15,""); DataGridColumnItem dgci=new DataGridColumnItem(); dgci.ColType=ColumnItemType.BindDataColumn; dgci.HeadText="人員編號"; dgci.BindField="UserCode"; dgci.Width="10%"; dg.addColumn(dgci); dgci=new DataGridColumnItem(); dgci.ColType=ColumnItemType.BindDataColumn; dgci.HeadText="人員姓名"; dgci.BindField="UserName"; dgci.Width="15%"; dg.addColumn(dgci); dgci=new DataGridColumnItem(); dgci.ColType=ColumnItemType.BindDataColumn; dgci.HeadText="公司"; dgci.BindField="CropName"; dgci.Width="10%"; dg.addColumn(dgci); dgci=new DataGridColumnItem(); dgci.ColType=ColumnItemType.BindDataColumn; dgci.HeadText="部門"; dgci.BindField="DepartName"; dgci.Width="15%"; dg.addColumn(dgci); dgci=new DataGridColumnItem(); dgci.ColType=ColumnItemType.BindDataColumn; dgci.HeadText="性別"; dgci.BindField="Sex"; dgci.Width="10%"; dg.addColumn(dgci); dgci=new DataGridColumnItem(); dgci.ColType=ColumnItemType.BindDataColumn; dgci.HeadText="職務"; dgci.BindField="RankName"; dgci.Width="20%"; dg.addColumn(dgci); dgci=new DataGridColumnItem(); dgci.ColType=ColumnItemType.LinkButtonColumn; //dgci.HeadText="編輯"; dgci.BindField="詳細信息"; dgci.Script="../employee/employee_all_info_detail.jsp?Key=[UserID]"; dgci.Width="20%"; dg.addColumn(dgci); String cropid=(String)session.getAttribute("cropid"); String roleid=(String)session.getAttribute("roleid"); //System.out.println("userid:"+userid); String Sql=""; //int a[]=new int[20]; String strCropID[]=new String[100]; String strDepartID[]=new String[100]; DataTable dt =new DataTable(); //String departid=(String)session.getAttribute("departid"); String mSql_competence="Select CropID,DepartID from leadquery02_competence c where c.UserID="+userid+" "; //System.out.println("testme"); //System.out.println("mSql_competence:"+mSql_competence); Sql="select DISTINCT a.UserID,UserCode,UserName,b.sex,"; Sql+=" CropName=(Select MachName from sys04_Machine c where a.CropID=c.MachID),"; Sql+=" DepartName=(select MachName from sys04_Machine d where a.DepartID=d.MachID ),"; Sql+=" RankName=(select RankName from Basic02_Rank where Rankid=rank)"; //Sql+=" from employee01_Basic a , employee02_info b "; //Sql+=" where a.UserID=b.UserID "; Sql+=" FROM employee01_Basic a LEFT OUTER JOIN employee02_info b ON a.UserID = b.UserID "; if(conn.querySql(mSql_competence,dt)){ if(dt.getRowCount()>0){ Sql+=" Where ( "; for(int i=0;i<dt.getRowCount();i++){ strCropID[i] = dt.getItemForName(i,"CropID"); strDepartID[i] = dt.getItemForName(i,"DepartID"); //System.out.println("strCropID:"+strCropID[i]); //System.out.println("strDepartID:"+strDepartID[i]); if(i>0 ){ Sql+=" OR "; } if(strDepartID[i] != null && strDepartID[i].equals("")==false ){ Sql+=" ( a.CropID="+strCropID[i]+" "; Sql+=" AND a.DepartID="+strDepartID[i]+" )"; } else{ Sql+=" ( a.CropID="+strCropID[i]+" )"; } } Sql+=" ) "; //System.out.println("Sqlleader1:"+Sql); } } //System.out.println("Sqlleader:"+Sql); String userstate=request.getParameter("userstate"); if (userstate!=null){ Sql+=" AND a.UserState='"+userstate+"' "; out.println("<script>document.all.userstate.value='"+userstate+"';</script>"); }else{ Sql+=" AND a.UserState='0' "; } String hiddensql=request.getParameter("hiddensql"); if (hiddensql!=null && hiddensql.length()>0){ Sql+=" and "+hiddensql; out.println("<script>document.all.hiddensql.value='"+hiddensql+"';</script>"); } if(strCorp.length()>0) Sql+=" AND a.CropID = "+PubClass.getString(strCorp)+" "; if (strDepart.length()>0 && strDepart.equals("Pselect")==false ) Sql+= " AND a.DepartID = "+PubClass.getString(strDepart)+" "; System.out.println("Sql:"+Sql); if (conn.execSql(Sql)){ } else{ response.setCharacterEncoding("GBK"); String LastOperMsg="不能讀取權限數據!"; out.println("<script>alert('"+LastOperMsg+"');window.returnValue=0;window.close();</script>"); } dg.bindSql(Sql); out.print(dg.ShowGrid()); %> <% String m1Script=""; m1Script=PubClass.BindAllCorp_Leader_List("document.all.Corp",userid); //m1Script=PubClass.BindAllCorpList2("document.all.Corp"); %> <%= m1Script%> <% String sLeaderList=""; //System.out.println("strDepart2:"+PubClass.getString(strDepart)); sLeaderList+="<script>document.all.Corp.value='"+PubClass.getString(strCorp)+"';</script>"; sLeaderList+="<script>document.all.Depart.value='"+PubClass.getString(strDepart)+"';</script>"; %> <%=sLeaderList%> <input type="hidden" name="HiddenKeyDepart" value="<%=strDepart%>" > <input type="hidden" name="HiddenUserId" value="<%=userid%>" > </form> </body> </html> 頁面錯誤如圖所示: 注意這裏的錯誤和order by的提示是一樣的,但問題不一樣。 爲了解決這個問題: 我們首先跟蹤程序:dg.ShowGrid(): 發現要執行:String num=conn.lookupfirst("select count(*) as cnum from ("+mSql+") as awqertc1q ","cnum"); 我們將上面打印的sql語句帶入這裏: SQl:select DISTINCT a.UserID,UserCode,UserName,b.sex, CropName=(Select MachName from sys04_Machine c where a.CropID=c.MachID), DepartName=(select MachName from sys04_Machine d where a.DepartID=d.MachID ), RankName=(select RankName from Basic02_Rank where Rankid=rank) FROM employee01_Basic a LEFT OUTER JOIN employee02_info b ON a.UserID = b.UserID Where ( ( a.CropID=1 ) OR ( a.CropID=202 AND a.DepartID=207 ) OR ( a.CropID=1 ) OR ( a.CropID=1 ) OR ( a.CropID=202 ) OR ( a.CropID=253 ) OR ( a.CropID=202 AND a.DepartID=207 ) OR ( a.CropID=202 AND a.DepartID=207 ) OR ( a.CropID=202 AND a.DepartID=209 ) OR ( a.CropID=202 ) OR ( a.CropID=204 ) OR ( a.CropID=204 ) ) AND a.UserState='0' 我們將它在sqlserver中執行,發現沒有問題: 我們再將它傳入到上面的lookupfirst函數當中,mSql爲上面打印的sql語句: select count(*) as cnum from ("+mSql+") as awqertc1q 結果顯示沒有問題(注意的是如果帶入排序,就會出現問題,這個問題比較深奧,我們以後再說。) 那麽這是什麽問題呢?難道真的是和排序一樣出現的實現小數據量和海量數據的通用分頁顯示存儲過程出現的問題一樣嗎?于是我也仿照對排序的解決方法一樣,在select前加入top 100 percent 但是卻不能顯示!!!! 如此難道這又是實現小數據量和海量數據的通用分頁顯示存儲過程出現的問題,而且是不同形式,連top 100 percen都不能用?我們再繼續跟蹤代碼,看看基礎代碼是怎麽實現的,如果要改動基礎代碼,將對整個系統産生巨大的影響。但出現問題我們必須解決,只好硬著頭皮看下去,爲了,跟蹤系統代碼: public String ShowGrid(){ try{ String Table=""; Conn conn=new Conn(); String num=conn.lookupfirst("select count(*) as cnum from ("+mSql+") as awqertc1q ","cnum"); if (num.trim().length()<1) num="0"; int CountNum=Integer.parseInt(num); int CurrentNum=1; if (mRequest.getParameter(getHiddenContolID())!=null){ String m=mRequest.getParameter(getHiddenContolID()); if (m.trim().length()<1) m="0"; CurrentNum=Integer.parseInt(m); } //if (mRequest.getParameter(getChangePageContolID())!=null){ // String m=mRequest.getParameter(getChangePageContolID()); // if (m.trim().equals("0")){ // CurrentNum=1; // } //} //Table+="select count(*) as cnum from ("+mSql+") as a "; int Pagecount= (CountNum+mRowInPage-1)/mRowInPage; Table+=getGridJavascriptFun(CurrentNum,CountNum,Pagecount); Table+=getGridTable(CurrentNum,CountNum,Pagecount); //System.out.println("Table:"+Table); return Table; }catch(Exception e){ return e.getMessage(); } } 我們將Table 打印出來: <script> function LastPage1Fun() { document.all.datagrid1_pageno.value='31'; document.all.datagrid1_changepage.value='1'; window.document.formlist.submit(); } function JumpPage1Fun(){ document.all.datagrid1_pageno.value=document.all.datagrid1_ump.value; document.all.datagrid1_changepage.value='1'; window.document.formlist.submit(); } function NextPage1Fun() { document.all.datagrid1_pageno.value='2'; document.all.datagrid1_changepage.value='1'; window.document.formlist.submit(); } function prePage1Fun() { document.all.datagrid1_pageno.value='1'; document.all.datagrid1_changepage.value='1'; window.document.formlist.submit(); } function FirstPage1Fun() { document.all.datagrid1_pageno.value='1'; document.all.datagrid1_changepage.value='1'; window.document.formlist.submit(); } function page1chk(id,trueOrFalse){ if(trueOrFalse==null) trueOrFalse=true; var chks=document.getElementsByName(id); for (var i=0;i<chks.length;i++) chks[i].checked=trueOrFalse; page1chkdata(id); } function page1chkdata(id){ document.all.datagrid1_checkvalue.value=''; var chks=document.getElementsByName(id); for (var i=0;i<chks.length;i++){ if (chks[i].checked){ document.all.datagrid1_checkvalue.value+=chks[i].value+','; } } var a=document.all.datagrid1_checkvalue.value.length ; if (a>0){ document.all.datagrid1_checkvalue.value=document.all.datagrid1_checkvalue.value.substr(0,a-1); } }</script> <body> <form> <input type='Hidden' Name='datagrid1_pageno' value='1'> <input type='Hidden' Name='datagrid1_changepage' value='0'> <table cellspacing='0' cellpadding='2' rules='all' TableBackColor='#DBDBDB' TablelineColor='#000000' TableWidth='100%' TableCellpadding='3' IsPicbutton='False' TitleColor='#000000' IsShowDelChk='True' PageNO='1' TableColor='#000000' Insert_ShowScroll='False' AllPage='1' bordercolor='#124D70' border='1' id='WGrid1' style='border-color:#124D70;width:100%;border-collapse:collapse;'> <tr class='ListTableHeader' align='Center' style='color:Black;background-color:#E7EFFF;'> <td style='width:10%;'>人員編號</td> <td style='width:15%;'>人員姓名</td> <td style='width:10%;'>公司</td> <td style='width:15%;'>部門</td> <td style='width:10%;'>性別</td> <td style='width:20%;'>職務</td> <td style='width:20%;'></td> </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'"> <td Align='center'>000001</td> <td Align='center'>唐運祥</td> <td Align='center'>總公司</td> <td Align='center'>公司領導</td> <td Align='center'>男</td> <td Align='center'></td> <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=1">詳細信息</a></td> </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'"> <td Align='center'>000002</td> <td Align='center'>傅助</td> <td Align='center'>總公司</td> <td Align='center'>公司領導</td> <td Align='center'>男</td> <td Align='center'></td> <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=2">詳細信息</a></td> </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'"> <td Align='center'>000003</td> <td Align='center'>宋福興</td> <td Align='center'>總公司</td> <td Align='center'>公司領導</td> <td Align='center'>男</td> <td Align='center'></td> <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=3">詳細信息</a></td> </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'"> <td Align='center'>000005</td> <td Align='center'>傅安平</td> <td Align='center'>總公司</td> <td Align='center'>公司領導</td> <td Align='center'>男</td> <td Align='center'></td> <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=4">詳細信息</a></td> </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'"> <td Align='center'>000006</td> <td Align='center'>松下敏彥</td> <td Align='center'>總公司</td> <td Align='center'>公司領導</td> <td Align='center'>男</td> <td Align='center'></td> <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=5">詳細信息</a></td> </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'"> <td Align='center'>000018</td> <td Align='center'>張海山</td> <td Align='center'>總公司</td> <td Align='center'>公司領導</td> <td Align='center'>男</td> <td Align='center'></td> <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=6">詳細信息</a></td> </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'"> <td Align='center'>000019</td> <td Align='center'>王夢飛</td> <td Align='center'>總公司</td> <td Align='center'>辦公室</td> <td Align='center'>女</td> <td Align='center'></td> <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=7">詳細信息</a></td> </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'"> <td Align='center'>000020</td> <td Align='center'>吳劍</td> <td Align='center'>總公司</td> <td Align='center'>辦公室</td> <td Align='center'>男</td> <td Align='center'></td> <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=8">詳細信息</a></td> </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'"> <td Align='center'>000021</td> <td Align='center'>徐喆</td> <td Align='center'>總公司</td> <td Align='center'>辦公室</td> <td Align='center'>男</td> <td Align='center'></td> <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=9">詳細信息</a></td> </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'"> <td Align='center'>000022</td> <td Align='center'>田靓</td> <td Align='center'>總公司</td> <td Align='center'>辦公室</td> <td Align='center'>男</td> <td Align='center'></td> <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=10">詳細信息</a></td> </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'"> <td Align='center'>000023</td> <td Align='center'>劉歆</td> <td Align='center'>總公司</td> <td Align='center'>辦公室</td> <td Align='center'>男</td> <td Align='center'></td> <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=11">詳細信息</a></td> </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'"> <td Align='center'>000024</td> <td Align='center'>巴音</td> <td Align='center'>總公司</td> <td Align='center'>辦公室</td> <td Align='center'>男</td> <td Align='center'></td> <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=12">詳細信息</a></td> </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'"> <td Align='center'>000025</td> <td Align='center'>于勇</td> <td Align='center'>總公司</td> <td Align='center'>辦公室</td> <td Align='center'>男</td> <td Align='center'></td> <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=13">詳細信息</a></td> </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'"> <td Align='center'>000026</td> <td Align='center'>彭曉敏</td> <td Align='center'>總公司</td> <td Align='center'>辦公室</td> <td Align='center'>女</td> <td Align='center'></td> <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=14">詳細信息</a></td> </tr><tr align='Center' onmouseover="objColor=this.style.backgroundColor;this.style.backgroundColor='#FFF0CC'" onmouseout='this.style.backgroundColor=objColor' style="color:#000066;'"> <td Align='center'>000027</td> <td Align='center'>楊建靈</td> <td Align='center'>總公司</td> <td Align='center'>辦公室</td> <td Align='center'>男</td> <td Align='center'></td> <td Align='center'><a href="../employee/employee_all_info_detail.jsp?Key=15">詳細信息</a></td> </tr><tr align="Right" style="color:#000066;background-color:#DFDFDF;"> <td colspan='7'> <table border="0" style="color:#000066;background-color:#DFDFDF;border-width:0px;width:100%;"> <tr> <td align="Left" style="width:15%;"> <a disabled="disabled" title="首頁" style="font-family:webdings;font-size: 11pt;" onclick="FirstPage1Fun(); ">9</a> <font style='font-family:Arial;font-size:9pt'> </font> <a disabled="disabled" title="上一頁" style="font-family:webdings;font-size: 11pt;">7</a> <font style='font-family:Arial;font-size:9pt'> </font> <a style="cursor:hand; color:#0A52CB" title="下一頁" style="font-family:webdings;font-size: 11pt;" onclick="NextPage1Fun();">8</a> <font style='font-family:Arial;font-size:9pt'> </font> <a title="尾頁" onclick="LastPage1Fun();" style="font-family:webdings;font-size: 11pt; ">:</a> </td><td align="Left" style="font-family:宋體;font-size:9pt"> 頁次:<font color="#E23000"> <input name='datagrid1_ump' class="input" type="text" value="1" maxlength="3" onchange="JumpPage1Fun(); " language="javascript" style="border-style:Groove;font-family:宋體;font-size:9pt;height:18px;width:18px;text-align :Center;" /><b>/31</b></font> 每頁<font color="#E23000"><b>15</b></font> 條 共有記錄<font color="red"><b>459</b></font>條 </td> </tr> </table> </td> </tr> </table> 然後新建一個頁面:1.jsp 在dreamver顯示結果如下 然後我們發現NextPage1Fun()是javscrip腳本,我想會不會是用于我的sql代碼中用了or所以導致NextPage1Fun()值有問題(可能哪個對象在莫中情況下未賦值),或者是我原先說過的小數據量和海量數據的通用分頁顯示存儲過程出現的問題,如此將要更改系統的基礎實現!!!,但是我們必須先將問題縮小到小的範圍內,不能先認定到莫個原因,這時分析程序和事務的關鍵,如此我們才能找到本質原因。 那麽由于領導權限上面的公司-部門聯動和其他地方不同,是采用不同的算法實現,會不會是它的問題,我于是將 <body onload="Change_Select(1)">中的onload="Change_Select(1)"去掉,以便消除此二級聯動的影響。但然而有問題。會不是是參數當莫個時候取空值造成的影響呢?但是那麽多參數如何確定?? 于是,我就想到了一個簡單辦法,從簡單到複雜一步一步叠代。 我先將第一頁顯示的sql語句取出,直接顯示,看是後台問題,還是是我原先說過的小數據量和海量數據的通用分頁顯示存儲過程出現的問題,因爲這裏用了OR這個特殊的關鍵字。(排序 需要在select語句前加 top 100 percent)。 <%@ page contentType="text/html; charset=gbk" language="java" import="java.sql.*" errorPage="" %> <%@ page import ="pub.*" %> <%@ page import="leader.*"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk"> </head> <body> <form name="formlist" method="post" action="test.jsp"> <input name="submit1" type="submit" class="button" style="WIDTH: 80px" value="查詢"> <% DataGrid dg=new DataGrid("1",request,"formlist",15,""); DataGridColumnItem dgci=new DataGridColumnItem(); dgci.ColType=ColumnItemType.BindDataColumn; dgci.HeadText="人員編號"; dgci.BindField="UserCode"; dgci.Width="10%"; dg.addColumn(dgci); dgci=new DataGridColumnItem(); dgci.ColType=ColumnItemType.BindDataColumn; dgci.HeadText="人員姓名"; dgci.BindField="UserName"; dgci.Width="15%"; dg.addColumn(dgci); dgci=new DataGridColumnItem(); dgci.ColType=ColumnItemType.BindDataColumn; dgci.HeadText="公司"; dgci.BindField="CropName"; dgci.Width="10%"; dg.addColumn(dgci); dgci=new DataGridColumnItem(); dgci.ColType=ColumnItemType.BindDataColumn; dgci.HeadText="部門"; dgci.BindField="DepartName"; dgci.Width="15%"; dg.addColumn(dgci); dgci=new DataGridColumnItem(); dgci.ColType=ColumnItemType.BindDataColumn; dgci.HeadText="性別"; dgci.BindField="Sex"; dgci.Width="10%"; dg.addColumn(dgci); dgci=new DataGridColumnItem(); dgci.ColType=ColumnItemType.BindDataColumn; dgci.HeadText="職務"; dgci.BindField="RankName"; dgci.Width="20%"; dg.addColumn(dgci); dgci=new DataGridColumnItem(); dgci.ColType=ColumnItemType.LinkButtonColumn; //dgci.HeadText="編輯"; dgci.BindField="詳細信息"; dgci.Script="../employee/employee_all_info_detail.jsp?Key=[UserID]"; dgci.Width="20%"; dg.addColumn(dgci); String Sql=""; Sql="select DISTINCT a.UserID,UserCode,UserName,b.sex, CropName=(Select MachName from sys04_Machine c where a.CropID=c.MachID), DepartName=(select MachName from sys04_Machine d where a.DepartID=d.MachID ), RankName=(select RankName from Basic02_Rank where Rankid=rank) FROM employee01_Basic a LEFT OUTER JOIN employee02_info b ON a.UserID = b.UserID Where ( ( a.CropID=1 ) OR ( a.CropID=202 AND a.DepartID=207 ) OR ( a.CropID=1 ) OR ( a.CropID=1 ) OR ( a.CropID=202 ) OR ( a.CropID=253 ) OR ( a.CropID=202 AND a.DepartID=207 ) OR ( a.CropID=202 AND a.DepartID=207 ) OR ( a.CropID=202 AND a.DepartID=209 ) OR ( a.CropID=202 ) OR ( a.CropID=204 ) OR ( a.CropID=204 ) ) AND a.UserState='0' "; dg.bindSql(Sql); out.print(dg.ShowGrid()); %> </form> </body> </html> 我們第一次沒有加查詢按鈕,發現程序沒問題,但是當加了查詢按鈕之後,竟然出了問題。說明這個查詢有問題!!!我向我們項目經理說明了情況,我以爲後台代碼與這個查詢有沖突,他說他曾經在網上看到了,這個<input name="submit" type="submit" class="button" style="WIDTH: 80px" value="查詢">的名字和type不能一樣!!! 將它改爲name="submit1",測試,問題解決。真是[url=http://www.dc9.cn/post/280.html]山窮水複疑無路,柳暗花明又一村[/url]。
󰈣󰈤
 
 
 
>>返回首頁<<
 
 
 
 
 熱帖排行
 
王朝網路微信公眾號
微信掃碼關註本站公眾號 wangchaonetcn
 
  免責聲明:本文僅代表作者個人觀點,與王朝網絡無關。王朝網絡登載此文出於傳遞更多信息之目的,並不意味著贊同其觀點或證實其描述,其原創性以及文中陳述文字和內容未經本站證實,對本文以及其中全部或者部分內容、文字的真實性、完整性、及時性本站不作任何保證或承諾,請讀者僅作參考,並請自行核實相關內容。
 
© 2005- 王朝網路 版權所有