我想從數據庫中明智地顯示每月的值。這裏是我fetchning代碼如何在mysql數據庫的jsp頁面中顯示月份名稱
<%
int i=1;
String country=request.getParameter("country");
Connection con=Singleton.getMySqlConnection();
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select MONTHNAME(start_date),Extract(year from start_date),Extract(day from start_date),event_name,state,country from conf_events where country='"+country+"' and type='approved' order by Extract(month from start_date),Extract(day from start_date) ");
%>
,我很喜歡在顯示jsp頁面
<%while(rs.next()){%>
<div class="alertbox">
<table border="0" cellPadding="0" cellspacing="0" width="100%" >
<tr valign="top" >
<th align="left"class="alertmonth" >
<%=rs.getString(1)%>-<%=rs.getString(2)%>
</th>
</tr>
<tr >
<table border="0" cellpadding="8" cellspacing="0" width="100%" style="margin-top:5px;" id="cnflist">
<tr>
<td width="20%"><%=rs.getString(3)%> th</td>
<td width="60%"><%=rs.getString(4)%></td>
<td width="20%"><%=rs.getString(5)%>, <%=rs.getString(6)%></td>
</tr>
但這裏中間的一個月丟失剩餘的結果,如果可能是前一個月下顯示,例如月失蹤,接下來6月份以及月後結果下4月月份。我希望每月明智地顯示詳細信息,如果中間一個(或)兩個月缺失,則按月明智地顯示可用月份詳情。 給我建議解決這個問題
讓我跟你說實話:這是一個可怕的寫JSP! – aquaraga
嘗試使用'jstl'和'el'.It會更好 – Deepak
我見過的最美麗的一段代碼(諷刺) – Makky