初学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”并不是一个对象。