首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

初学JSP,请问一下,小弟我下面代码的有关问题

2012-03-04 
初学JSP,请教一下,我下面代码的问题!divid dv style height:300pxwidth730overflow-y:auto ta

初学JSP,请教一下,我下面代码的问题!
<div   id= "dv "   style= "height:300px;   width   =   730;   overflow-y:auto ">  
                                        <table   width= "720 "   border= "1 "   class= "negoList "   cellspacing= "0 "   cellpadding= "0 "   bordercolor= "#0A336D ">
                                                <%
int   datanumber=   -1;
for(int   i=0;i <customcomment_list.size();i++){
CustomerComment   customercomment=(CustomerComment)customcomment_list.get(i);
String   timeformat   =   customercomment.getINSERTED_TM();//   @return   String   登録日
SimpleTime   simpletime   =   new   SimpleTime();
String   timeshow   =   simpletime.turnToOutputDate(timeformat);
String   checkboxname   =   "deleteObject "+i;
String   timename   =   "timeObject "+i;
datanumber   =   i;
%>
                                                <tr   class= "light ">  
                                                        <td   width= "59 ">   <input   type= "checkbox "   name= " <%=checkboxname%> "   value= "Y ">  
                                                                <input   type= "hidden "   name= " <%=timename%> "   value= " <%=timeformat%> ">  
                                                        </td>
                                                        <td   width= "89 "> <%=timeshow%> </td>
                                                        <td   width= "101 "> <%=hashmapmember.get(customercomment.getINSERTED_ID())%>  
                                                        </td>
                                                        <td   width= "461 "> <%=customercomment.getCONTENT()%> </td> <!--   getCONTENT()@return   String   固有情報内容-->


                                                </tr>
                                                <input   type= "hidden "   name= "datanumber "   value= " <%=datanumber%> ">
                                        </table>    
                                              <%}%>
                                        <br>
          契約先CD情報 <br>
                <table   width= "720 "   class= "negoList "   border= "1 "   cellspacing= "0 "   cellpadding= "0 "   bordercolor= "#0A336D ">
                                                <tr   class=heading   >  
                                                <td   class=contentIP   width= "60 ">   削除対象   </td>
                                                <td   class=contentIP   width= "90 ">   登録日   </td>
                                                <td   class=contentIP   width= "100 ">   登録者   </td>
                                                <td   class=contentIP   width= "460 ">   コメント   </td>
                                                </tr>
                                            </table>    
                                            <%  
                                                int   data=   -1;
for(int   k=0;k <customcomment_list.size();k++){
CustomerComment   cdcustomercomment=(CustomerComment)customcomment_list.get(k);
String   cdtimeformat   =   cdcustomercomment.getINSERTED_TM();//   @return   String   登録日
SimpleTime   cdsimpletime   =   new   SimpleTime();


String   cdtimeshow   =   cdsimpletime.turnToOutputDate(cdtimeformat);
String   cdcheckboxname   =   "deleteObject "+k;
String   cdtimename   =   "timeObject "+k;
data   =   k;
          %>
<%if(cdcustomercomment.getFlag()== "0 "){%>                
          <table   width= "720 "   border= "1 "   class= "negoList "   cellspacing= "0 "   cellpadding= "0 "   bordercolor= "#0A336D ">
                                                          <tr   class= "light ">  
                                                          <td   width= "59 "> <input   type= "checkbox "   name= " <%=cdcheckboxname%> "   value= "Y ">  
                                                                <input   type= "hidden "   name= " <%=cdtimename%> "   value= " <%=cdtimeformat%> ">  
                                                          </td>
                                                          <td   width= "89 "> <%=cdtimeshow%> </td>
                                                            <td   width= "101 "> <%=hashmapmember.get(cdcustomercomment.getINSERTED_ID())%> <!--return   String   登録者ID   -->
                                                          </td>
                                                          <td   width= "461 "> <%=cdcustomercomment.getCONTENT()%> </td> <!--   getCONTENT()@return   String   固有情報内容-->
                                                    </tr>
                                                    </table>
                                            <%   }else{%> <%}%>


                                        <%}%>

                                </div>


---------------------------------
当只有下面代码时,显示是正确的:
                                        <table   width= "720 "   border= "1 "   class= "negoList "   cellspacing= "0 "   cellpadding= "0 "   bordercolor= "#0A336D ">
                                                <%
int   datanumber=   -1;
for(int   i=0;i <customcomment_list.size();i++){
CustomerComment   customercomment=(CustomerComment)customcomment_list.get(i);
String   timeformat   =   customercomment.getINSERTED_TM();//   @return   String   登録日
SimpleTime   simpletime   =   new   SimpleTime();
String   timeshow   =   simpletime.turnToOutputDate(timeformat);
String   checkboxname   =   "deleteObject "+i;
String   timename   =   "timeObject "+i;
datanumber   =   i;
%>
                                                <tr   class= "light ">  
                                                        <td   width= "59 ">   <input   type= "checkbox "   name= " <%=checkboxname%> "   value= "Y ">  
                                                                <input   type= "hidden "   name= " <%=timename%> "   value= " <%=timeformat%> ">  
                                                        </td>
                                                        <td   width= "89 "> <%=timeshow%> </td>
                                                        <td   width= "101 "> <%=hashmapmember.get(customercomment.getINSERTED_ID())%>  
                                                        </td>
                                                        <td   width= "461 "> <%=customercomment.getCONTENT()%> </td> <!--   getCONTENT()@return   String   固有情報内容-->


                                                </tr>
                                                <input   type= "hidden "   name= "datanumber "   value= " <%=datanumber%> ">
                                        </table>    
                                              <%}%>



[解决办法]
cdcustomercomment.getFlag()== "0 "
改为cdcustomercomment.getFlag().equals( "0 ")试试,字符串的比较不能使用==,因为这样表示两个对象的比较,虽然取出的值也是“0”,但是和“0”并不是一个对象。

热点排行