首页 新闻 会员 周边

jsp页面上有三个循环,到现在一个小时了,也没有打开Jsp页面,怎么解决呢?

0
悬赏园豆:30 [已解决问题] 解决于 2013-09-19 10:02

jsp页面上有三个循环,到现在一个小时了,也没有打开Jsp页面,这是怎么回事啊?有没有好的办法解决呢?

因为写了俩个sql,就会有俩个list。。。。

jsp
培培@java的主页 培培@java | 初学一级 | 园豆:38
提问于:2013-09-17 15:30
< >
分享
最佳答案
0

你这个截图是哪里的?还有三个循环?你说的是javascript的?还是后台的java代码?描述清楚才能更好地判断问题、

收获园豆:30
Beyond-bit | 老鸟四级 |园豆:2885 | 2013-09-17 16:00

这是jsp显示页面,执行过程中,是java代码

  for(int k0 = 0;k0<schema.size();k0++){    
        int k1;
        int k;
        %>
            <tr>
            
            <%
        for(k = 0;k<=k0;k++){                            
            web_R_RepolicyMainInfoDto = (Web_R_RepolicyMainInfoDto)schema.get(k) ;
            String policyNo = web_R_RepolicyMainInfoDto.getPolicyNo();    
            double dangerNo = web_R_RepolicyMainInfoDto.getDangerNo();
            String comCode = web_R_RepolicyMainInfoDto.getComCName();
            String riskName = web_R_RepolicyMainInfoDto.getRiskName();
            String insuredName = web_R_RepolicyMainInfoDto.getInsuredName();
            String occupancyName = web_R_RepolicyMainInfoDto.getOccupancyName();
            String startDate = String.valueOf(web_R_RepolicyMainInfoDto.getStartDate());
            String endDate = String.valueOf(web_R_RepolicyMainInfoDto.getEndDate());
          
            String currency = web_R_RepolicyMainInfoDto.getCurrencyName();
             double baseAmount = web_R_RepolicyMainInfoDto.getBaseAmount();
             double basePremium = web_R_RepolicyMainInfoDto.getBasePremium();
            double allTotReamount=web_R_RepolicyMainInfoDto.getAllTotReamount();//合约总分出保额 2013-9-12 WPP
           
            
            
            
            
            totBaseAmount += baseAmount;
            totBasePremium += basePremium;
            totallTotReamount +=allTotReamount;//2013-9-12 WPP
            
             
%>
     
      <td  align="left" nowrap><%= k+1%></td>
      <td  align="left" nowrap><%= policyNo %>&lrm;</td>
    <td  align="left" nowrap><%= comCode%></td>
    <td  align="left" nowrap><%= riskName %></td>
    <td  align="left" nowrap><%= insuredName%></td>
    <td  align="left" nowrap><%= startDate + "--" + endDate%></td>
    <td  align="left" nowrap><%= currency%></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(baseAmount) %></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(basePremium)%></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(allTotReamount)%></td><!--2013-9-12 WPP  -->
     <%-- <td  align="left" nowrap><%= treatyName %></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(reAmount)%></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(rePremium)%></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(totRePaid)%></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(totReOutStand)%></td>--%>

    <%

    
    int j=0;
    for(k1=0;k1<schema1.size();k1++){
        
        j=j+1;
   // web_R_RepolicyMainInfoDto1 =  (Web_R_RepolicyMainInfoDto1)schema1.get(k1-1) ;
    web_R_RepolicyMainInfoDto1 =  (Web_R_RepolicyMainInfoDto1)schema1.get(k1) ;
    web_R_RepolicyMainInfoDto2 =  (Web_R_RepolicyMainInfoDto1)schema1.get(k1+1) ;
    //out.print(web_R_RepolicyMainInfoDto1.getPolicyNo());
    //out.print(web_R_RepolicyMainInfoDto2.getPolicyNo());
   // out.print(web_R_RepolicyMainInfoDto3.getPolicyNo());
    
    String treatyName1 = web_R_RepolicyMainInfoDto1.getTreatyName();
     double reAmount1 = web_R_RepolicyMainInfoDto1.getReAmount();
     double rePremium1 = web_R_RepolicyMainInfoDto1.getRePremium();
    double totRePaid1 = web_R_RepolicyMainInfoDto1.getTotRePaid();
    double totReOutStand1= web_R_RepolicyMainInfoDto1.getTotReOutstand();
    
    String treatyName2 = web_R_RepolicyMainInfoDto2.getTreatyName();
     double reAmount2 = web_R_RepolicyMainInfoDto2.getReAmount();
     double rePremium2 = web_R_RepolicyMainInfoDto2.getRePremium();
    double totRePaid2 = web_R_RepolicyMainInfoDto2.getTotRePaid();
    double totReOutStand2 = web_R_RepolicyMainInfoDto2.getTotReOutstand();
    
    totRePremium1 += rePremium1;
    totReAmount1 += reAmount1;
    totalRePaid1 += totRePaid1;
    totalReOutStand1 += totReOutStand1;
    
    totRePremium2 += rePremium2;
    totReAmount2 += reAmount2;
    totalRePaid2 += totRePaid2;
    totalReOutStand2 += totReOutStand2;
    
    
    if(web_R_RepolicyMainInfoDto.getRepolicyNo()!=web_R_RepolicyMainInfoDto1.getRepolicyNo()){
         for(int m=0;m<countTreatyNo-j;m++){
             %>
               <td  align="left" nowrap></td>
                <td  align="left" nowrap></td>
                <td  align="left" nowrap></td>
                <td  align="left" nowrap></td>
                <td  align="left" nowrap></td>
            <%
         }
        
         break;    
    }
 
        
    %>
    <td  align="left" nowrap><%= treatyName1 %></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(reAmount1)%></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(rePremium1)%></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(totRePaid1)%></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(totReOutStand1)%></td>
<%}
    
         %>
    
        
  </tr>
<%
}}
%>

培培@java | 园豆:38 (初学一级) | 2013-09-17 16:05

@培培@java: schema1和schema1的长度大概多少?设个断点看一下

会长 | 园豆:12401 (专家六级) | 2013-09-17 16:09

@会长: 大概是20,如果我选择没有数据时,就会出现

如果有数据,就会很慢,也许会一直不出来结果。。。

培培@java | 园豆:38 (初学一级) | 2013-09-17 16:15

@会长: 有代码格式工具,你不用?

 

有两种情况:1.你的for 嵌套循环问题、2.你的后台数据库交互没有关闭连接,释放资源、

Beyond-bit | 园豆:2885 (老鸟四级) | 2013-09-17 16:43

@培培@java: 

有代码格式工具,你不用?

 

有两种情况:1.你的for 嵌套循环问题、2.你的后台数据库交互没有关闭连接,释放资源、3.你的页面引入了错误的js文件、

Beyond-bit | 园豆:2885 (老鸟四级) | 2013-09-17 16:50

@会长: 艹。到底是谁在提问啊?哈哈哈、

Beyond-bit | 园豆:2885 (老鸟四级) | 2013-09-17 16:50

@会长: 哈哈、你得分 ?你要笑死我啊、

Beyond-bit | 园豆:2885 (老鸟四级) | 2013-09-17 17:09
其他回答(3)
0

有没有哪里有死循环?

就有三个循环也不应该这么慢啊

Albert Fei | 园豆:2102 (老鸟四级) | 2013-09-17 15:55

这是部分代码,我感觉不是死循环啊?

<%      
      
        List schema = (List)request.getAttribute("schema");
        String treatyName ="";
         double reAmount =0.00;
         double rePremium = 0.00;
        double totRePaid = 0.00;
        double totReOutStand = 0.00;
        List schema1 = (List)request.getAttribute("schema1");
       
        Web_R_RepolicyMainInfoDto web_R_RepolicyMainInfoDto = new Web_R_RepolicyMainInfoDto();
        Web_R_RepolicyMainInfoDto1 web_R_RepolicyMainInfoDto1 = new Web_R_RepolicyMainInfoDto1();
        Web_R_RepolicyMainInfoDto1 web_R_RepolicyMainInfoDto2 = new Web_R_RepolicyMainInfoDto1();
        Web_R_RepolicyMainInfoDto1 web_R_RepolicyMainInfoDto3 = new Web_R_RepolicyMainInfoDto1();
        double totBaseAmount = 0;
        double totBasePremium = 0;
        double totallTotReamount=0;
        
        double totalRePaid = 0;
        double totalReOutStand = 0;
        double totReAmount = 0;
        double totRePremium = 0;
        
        double totalRePaid1 = 0;
        double totalReOutStand1 = 0;
        double totReAmount1 = 0;
        double totRePremium1 = 0;
        
        double totalRePaid2 = 0;
        double totalReOutStand2 = 0;
        double totReAmount2 = 0;
        double totRePremium2 = 0;
        for(int k0 = 0;k0<schema.size();k0++){    
        int k1;
        int k;
        %>
            <tr>
            
            <%
        for(k = 0;k<=k0;k++){                            
            web_R_RepolicyMainInfoDto = (Web_R_RepolicyMainInfoDto)schema.get(k) ;
            String policyNo = web_R_RepolicyMainInfoDto.getPolicyNo();    
            double dangerNo = web_R_RepolicyMainInfoDto.getDangerNo();
            String comCode = web_R_RepolicyMainInfoDto.getComCName();
            String riskName = web_R_RepolicyMainInfoDto.getRiskName();
            String insuredName = web_R_RepolicyMainInfoDto.getInsuredName();
            String occupancyName = web_R_RepolicyMainInfoDto.getOccupancyName();
            String startDate = String.valueOf(web_R_RepolicyMainInfoDto.getStartDate());
            String endDate = String.valueOf(web_R_RepolicyMainInfoDto.getEndDate());
          
            String currency = web_R_RepolicyMainInfoDto.getCurrencyName();
             double baseAmount = web_R_RepolicyMainInfoDto.getBaseAmount();
             double basePremium = web_R_RepolicyMainInfoDto.getBasePremium();
            double allTotReamount=web_R_RepolicyMainInfoDto.getAllTotReamount();//合约总分出保额 2013-9-12 WPP
           
            
            
            
            
            totBaseAmount += baseAmount;
            totBasePremium += basePremium;
            totallTotReamount +=allTotReamount;//2013-9-12 WPP
            
             
%>
     
      <td  align="left" nowrap><%= k+1%></td>
      <td  align="left" nowrap><%= policyNo %>&lrm;</td>
    <td  align="left" nowrap><%= comCode%></td>
    <td  align="left" nowrap><%= riskName %></td>
    <td  align="left" nowrap><%= insuredName%></td>
    <td  align="left" nowrap><%= startDate + "--" + endDate%></td>
    <td  align="left" nowrap><%= currency%></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(baseAmount) %></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(basePremium)%></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(allTotReamount)%></td><!--2013-9-12 WPP  -->
     <%-- <td  align="left" nowrap><%= treatyName %></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(reAmount)%></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(rePremium)%></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(totRePaid)%></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(totReOutStand)%></td>--%>

    <%

    
    int j=0;
    for(k1=0;k1<schema1.size();k1++){
        
        j=j+1;
   // web_R_RepolicyMainInfoDto1 =  (Web_R_RepolicyMainInfoDto1)schema1.get(k1-1) ;
    web_R_RepolicyMainInfoDto1 =  (Web_R_RepolicyMainInfoDto1)schema1.get(k1) ;
    web_R_RepolicyMainInfoDto2 =  (Web_R_RepolicyMainInfoDto1)schema1.get(k1+1) ;
    //out.print(web_R_RepolicyMainInfoDto1.getPolicyNo());
    //out.print(web_R_RepolicyMainInfoDto2.getPolicyNo());
   // out.print(web_R_RepolicyMainInfoDto3.getPolicyNo());
    
    String treatyName1 = web_R_RepolicyMainInfoDto1.getTreatyName();
     double reAmount1 = web_R_RepolicyMainInfoDto1.getReAmount();
     double rePremium1 = web_R_RepolicyMainInfoDto1.getRePremium();
    double totRePaid1 = web_R_RepolicyMainInfoDto1.getTotRePaid();
    double totReOutStand1= web_R_RepolicyMainInfoDto1.getTotReOutstand();
    
    String treatyName2 = web_R_RepolicyMainInfoDto2.getTreatyName();
     double reAmount2 = web_R_RepolicyMainInfoDto2.getReAmount();
     double rePremium2 = web_R_RepolicyMainInfoDto2.getRePremium();
    double totRePaid2 = web_R_RepolicyMainInfoDto2.getTotRePaid();
    double totReOutStand2 = web_R_RepolicyMainInfoDto2.getTotReOutstand();
    
    totRePremium1 += rePremium1;
    totReAmount1 += reAmount1;
    totalRePaid1 += totRePaid1;
    totalReOutStand1 += totReOutStand1;
    
    totRePremium2 += rePremium2;
    totReAmount2 += reAmount2;
    totalRePaid2 += totRePaid2;
    totalReOutStand2 += totReOutStand2;
    
    
    if(web_R_RepolicyMainInfoDto.getRepolicyNo()!=web_R_RepolicyMainInfoDto1.getRepolicyNo()){
         for(int m=0;m<countTreatyNo-j;m++){
             %>
               <td  align="left" nowrap></td>
                <td  align="left" nowrap></td>
                <td  align="left" nowrap></td>
                <td  align="left" nowrap></td>
                <td  align="left" nowrap></td>
            <%
         }
        
         break;    
    }
 
        
    %>
    <td  align="left" nowrap><%= treatyName1 %></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(reAmount1)%></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(rePremium1)%></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(totRePaid1)%></td>
    <td  align="left" nowrap><%= FormatUtil.douToDouFormat(totReOutStand1)%></td>
<%}
    
         %>
    
        
  </tr>
<%
}}
%>

支持(0) 反对(0) 培培@java | 园豆:38 (初学一级) | 2013-09-17 16:00

@培培@java: 大约有多少数据量?

支持(0) 反对(0) Albert Fei | 园豆:2102 (老鸟四级) | 2013-09-17 16:32

@Albert Fei: 大约有20条。。。很少的,我差小部分,都不显示的。。。。

支持(0) 反对(0) 培培@java | 园豆:38 (初学一级) | 2013-09-17 16:34

@培培@java: 设个断点看看是哪步慢 这么少数据理论上不会出现这样问题的

你也可以先去掉哪一层的循环后 运行下看看什么情况。

多试几次会找出原因的

支持(0) 反对(0) Albert Fei | 园豆:2102 (老鸟四级) | 2013-09-17 16:48
0

感觉智商被压制了。。。

差生 | 园豆:3 (初学一级) | 2013-09-17 15:58

我已经智商为0了。。。

支持(0) 反对(0) 培培@java | 园豆:38 (初学一级) | 2013-09-17 16:07
0

断点,调试,保留某一个循环,远行;重复以上操作,看看是那个出问题了,楼上说的很明白了,循环体或者后台数据库交互问题,我是路过的酱油党

二十四号同学 | 园豆:216 (菜鸟二级) | 2013-09-17 18:08
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册