数据库中有数据!每个分类不止一个,怎么在页面显示每个分类只有一个?
谢谢!!!!<table width="1033" height="965" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="1033" height="965" align="center" valign="top"><table width="1024" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="44" align="center"><img src="images/products.gif" width="994" height="44"></td>
            </tr>
          </table>
            <table width="994" align="center" cellpadding="0" cellspacing="0" border="1" bordercolor="#66DCF9">
              <tr>
                <td height="945" align="center" valign="top"><table width="980" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="16"> <img src="images/list1.gif" width="215" height="32" align="left" border="0"></td>
                  </tr>
                  <tr> <c:forEach var="type1" items="${requestScope.list1}" varStatus="status">
                 
                    <td height="190" valign="top"><a href="picture.do?method=queryPictureInfoAll">  <img src="picture/<bean:write name="type1" property="pname"/>" width="145" height="167" border="0"> </a></td>
                  
                  </c:forEach></tr>
                </table><br>
                  <table width="980" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td height="16"><img src="images/list2.gif" width="215" height="27" align="left" border="0"></td>
                    </tr>
                    <tr> <c:forEach var="type2" items="${requestScope.list2}" varStatus="status">
                   
                      <td height="190"><a href="picture.do?method=queryPictureInfoAll">  <img src="picture/<bean:write name="type2" property="pname"/>" width="145" height="167" border="0"> </a></td>
                  
                    </c:forEach>  </tr>
                  </table><br>
                  <table width="980" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td height="16"><img src="images/list3.gif" width="215" height="33" align="left" border="0"></td>
                    </tr>
                     <tr><c:forEach var="type3" items="${requestScope.list3}" varStatus="status">
                   
                      <td height="190"><a href="picture.do?method=queryPictureInfoAll">  <img src="picture/<bean:write name="type3" property="pname"/>" width="145" height="167" border="0"> </a></td>
                  
                    </c:forEach>  </tr>
                  </table><br>
                  <table width="980" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td height="16" align="left" valign="middle"><img src="images/list4.gif" width="217" height="30" border="0"></td>
                    </tr>
                    <tr><c:forEach var="type4" items="${requestScope.list4}" varStatus="status">
                    
                      <td height="190"><a href="picture.do?method=queryPictureInfoAll">  <img src="picture/<bean:write name="type4" property="pname"/>" width="145" height="167" border="0"> </a></td>
                    
                    </c:forEach></tr>
                </table></td>
              </tr>
          </table>

解决方案 »

  1.   

    说的不清楚?
    你是指 分类有很多条记录,怎么让相同的记录只显示一条?
    如果是这样,可以数据进行GROUD BY一下 分组查询,
    另外一种方式,把取得的记录放进SET集合里,不放LIST里,
    SET里会自动过滤相同记录
      

  2.   

    jsp文件没什么问题.
    你的list1到list4,是怎么从数据库里面取出来并装入到LIST中的?
    检查一下那里的代码.
      

  3.   

    方法有2:
    1、从数据库入手:用group by 进行分组查询
    2、将list中的数据取出放到集合类Collections中进行过滤,或是放入list中进行比较。