表单查询显示翻页等不可用,提示对象不支持此属性或方法,切记查询按钮的name值不能为submit

本文介绍了一个关于查询按钮名称设置不当导致的分页功能失效问题,并给出了具体的解决方案。通过修改查询按钮的name属性避免了与默认提交按钮冲突,从而解决了翻页功能无法正常使用的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

切记查询按钮的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语句带入这里:

SQlselect  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:# 0A 52CB"     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"测试,问题解决。真是山穷水复疑无路,柳暗花明又一村

 
条件组合MySQL数据库密码是220603,我提供一个excel文档,我可以将这个文档进行导入到我的HTML页面里面的导入按钮,端口号为5008 导入功能:店铺管理(添加,修改,删除店铺的功能),通过输入店铺码和店铺名称来添加,添加完成之后会有一个进行导入店铺数据功能,这个就通过一个选择文件(如excel和csv),我认为在MySQL数据库里面创建表太麻烦了,只想创建一个数据库名字为shop_order,然后根据导入文件的第一行的所有表名字作为关键字创建所对应的MySQL表放在shop——oeder下面(如将Paid Time自动识别为DATETIME类型),切记这个关键字就是导入文档表的第一行,并且下面都是该关键字所对应的所有数据,由于我所做的系统需要导入三个文档,所以要设置三个导入数据的按钮,分别为All order,in come,creater order这三个表所对应了所有订单数据,收入订单数据和达人订单数据(也就是通过达人带货卖出去的订单)。 查询功能:在导入需要的数据之后,我们需要进行数据查询,目前先通过店铺码和店铺名称查询店铺,查询成功后进入店铺,这个时候我们需要再查询店铺的数据,这个时候就需要通过查询我们目前需要的数据,有最开始得到的关键字:Order ID,Paid Time(付款时间),还要给这个数据排列,也就是在这两个查询数据前面还需要建立一个Shop ID作为编号如01,02,03等等,查询显示的完整数据的是[Shop ID:Order ID,Paid Time],实现上面功能还够,我希望还可以增加一个时间查询也就是可以输入某个时间段到某个时间段来进行查询这段时间所有订单的数据,列如Start time[年月日]——End timr[年月日],这个时间查询是通过最开始得到的关键字里面的Paid Time所对应的时间数据("10/07/2025 10:24:31 " )来决定,因为是每个订单号Order ID都会被进行付款(paid_time),我们只需要提前这个付款时间需要其他时间,所以只需要查询有paid_time的Order ID并且提取出来即可,若没有paid_time数据就直接跳过放弃,继续查询有paid_time的数据订单即可,根据以上要求给出这个项目的开发教程,要求保姆级教程,再说一遍,在里面必须有可以导入excel和csv文档的功能,并且是点击导入数据就可以在我的电脑里面查找选择文档。要注意下面几个问题,第一:日期时间列识别问题:系统错误地将非日期列(如 Order_Status、Quantity)识别为日期列,日期转换失败率高(如 Created_Time 只有33.4%的转换成功率),错误提示:列 XXX 保持原样: 日期格式识别率低 (0.0%)原因是:仅通过列名关键词(如包含"time")判断是否为日期列,缺乏数据内容验证,未排除明确非日期列的字段(如状态、数量、金额等),未处理多种日期格式(如 10/07/2023 10:24:31 和 2023-07-10T15:45:00),一定要增强列识别逻辑,还有多格式日期解析和分阶段验证。 第二:数据类型推断错误:避免数列(如 Quantity)被误识别为日期,数据库插入时报错:Incorrect datetime value: '579567909575820736' for column 'Order ID',原因是因为类型推断仅基于列名,未结合数据内容,未处理大整数和特殊格式数字。所以要设置一个优先级调整和安全转换。 第三:数据库交互问题,特别是RuntimeError: The session is unavailable because no secret key was set,事务回滚失败导致表残留,数据类型匹配(如DATETIME和VARCHAR冲突)原因是Flask会话密钥未配置未正确处理MySQL错误代码(如1292=日期格式错误)和表结构创建与数据插入逻辑分离。所以要做到基础配置和事务管理和原子性操作这三个方面。 第四:前端模板渲染问题: 问题表现: jinja2.exceptions.TemplateNotFound jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'id' JavaScript中 const report = {{ date_report|tojson|safe }} 报错 根本原因: 模板文件未放在正确目录(templates/),变量未定义为None时直接调用方法,未处理JSON序列化中的None,解决方案:设置目录结构规范和安全变量访问以及默认处理。 第五: 文件上传与数据处理问题: 问题表现: 上传的Excel/CSV文件解析失败 临时文件未清理 列名含空格导致SQL错误 根本原因: 未验证文件内容格式 未处理文件编码问题(如UTF-8 vs GBK) 未规范化列名(如 Paid Time → Paid_Time) 解决方案:设置文件预处理和资源清理和编码指定。 第六:分页与性能问题: 问题表现: 大数据量查询时内存溢出 分页逻辑错误(LIMIT/OFFSET计算) 解决方案:设置流式查询和分页优化。 最后做一些优化比如:系统架构改进建议 日志监控: python代码: app.logger.addHandler(logging.FileHandler('import_errors.log')) 配置分离: python代码: class DevelopmentConfig(Config): DEBUG = True UPLOAD_FOLDER = '/tmp/uploads' 单元测试: python代码: def test_datetime_detection(): assert is_potential_datetime_column("Paid_Time", pd.Series(["2023-01-01"])) is True 根据上面所有要求和问题还有解决方法制定一个Python电商数据分析系统教程,要求保姆级教程!!!请仔细分析我给出的所有问题并且一一解决生成一个完整教程,要求准确并且代码质量高可以运行
最新发布
07-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值