jsp頁面換行輸出

來源:互聯網
上載者:User

if(skins != null){<br /> Iterator it = skins.keySet().iterator();<br /> // 關鍵代碼<br /> int i=0;<br /> while(it.hasNext()){<br /> String key = (String) it.next();<br /> SkinEntry skin = (SkinEntry)skins.get(key);<br /> String skinName = skin.getName();<br /> String skinTitle = skin.getTitle();<br /> String imageNormal = skin.getImage_normal();<br /> String author = skin.getAuthor();<br /> String deplytime = skin.getDeploytime();<br /> // 關鍵代碼<br /> if(i%3==0) out.println("<tr>") ;<br /> String onclick = "onclick=/"doSelectSkin('"+skinName+"')/"";<br /> String onmousemove = "onmousemove=/"className='select_on_style'/"";<br /> String onmouseout = "onmouseout=/"className=''/"";<br /> String sClass = "";<br /> String sImag = "";<br /> if(skinName.equals(sCurrent_skin)){<br /> sClass = "class=/"select_on_style/"";<br /> onmousemove = "";<br /> onmouseout = "";<br /> onclick = "";<br /> sImag = "<img src="/" mce_src="/""/images/skin_select.gif/">";<br /> }<br /> %><br /> <td><br /> <table height="180px" <%=sClass%> cellpadding="" cellspacing="3" <%=onclick%> width="220px" <%=onmousemove%> <%=onmouseout%>><br /> <tr><br /> <td align="center"><img src="<%=imageNormal%>"/><%=sImag%></td><br /> </tr><br /> <tr><br /> <td align="center"><%=skinTitle%></td><br /> </tr><br /> <tr><br /> <td align="center">作者:<%=author%></td><br /> </tr><br /> <tr><br /> <td align="center">發布時間:<%=deplytime%></td><br /> </tr><br /> </table><br /> </td><br /> // 關鍵代碼<br /> <%<br /> if((i+1)%3==0) out.println("</tr>") ;<br /> i++;<br /> }<br /> if(skins.size()%3!=0) {<br /> out.println("<td colspan='" + (3 - skins.size()%3) + "'>&nbsp;</td></tr>") ;<br /> }<br /> }%>

以上代碼為,每輸出三個td還一行,最後不夠用空的td代替。例如:輸出5個內容,第二行就不夠了,為了是代碼完整,在這裡就以<td>&nbps;</td>來進行填充。這個地方經常會在頁面顯示圖片預覽是用到。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.