求大神帮忙,我想把图书按每行4本显示,怎么做?

<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%><%--导入JSTL标签库 --%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${TYPE}</title>
<link rel="stylesheet" type="text/css" href="Books.css"/>
</head>

<body>
<div name="title">
	<table align="center">
    	<tr>
        	<td colspan="4"><img id="logo" src="image/logo.png"/></td>
          <td colspan="4"><h1>图书你的神话</h1></td>
          <td><a href="login.jsp"><input type="submit" value="登录" class="submit"/></a></td>
          <td><a href="NewUser.jsp"><input type="submit" value="注册" class="submit"/></a></td>
      </tr>
    </table>
</div>
<div>
	<table align="center">
    	<c:choose>
    		<c:when test="${BOOKS!=null}"><%--指定类型图书列表存在 --%>
    			<c:forEach var="b" items="${BOOKS}" varStatus="status"><%--遍历指定类型图书列表 --%>
    				<c:if test="${status.index%2==0}">
    					<tr>
				        	<td>
				            	<li><img height="150px" width="150px" src="${b.getBimage()}" /></li>
				                <li>${b.getBname()}</li>
				                <li>¥${b.getPrice()}</li>
				            </td>
        				</tr>
    				</c:if>
    				<c:if test="${status.index%2!=0}">
    					<td>
			            	<li><img height="150px" width="150px" src="${b.getBimage()}" /></li>
			                <li>${b.getBname()}</li>
			                <li>¥${b.getPrice()}</li>
				         </td>
    				</c:if>
    			</c:forEach>
    		</c:when>
    		<c:otherwise><%--指定类型图书列表不存在 --%>
    			<tr><td>对不起,指定类型图书不存在!</td></tr>
    		</c:otherwise>
    	</c:choose>
        <tr>
        	<td width="100%" align="center"><a href="#" >下一页</a>
    		<a href="#">末页</a></td>
        </tr> 
    </table>
</div>

<div id="end">
<hr color="#993300"/>
<p align="center">版权所有&copy;工作室</p>
<p align="center">手机版下载:<a href="#">Android</a>|<a href="#">Iphone</a></p>
<p align="center">联系我们:1383838438</p>
</div>
</body>
</html>

http://img.mukewang.com/572ec72c0001451110510623.jpg

yuantongxin
浏览 1395回答 1
1回答

看风听雨雪

<c:forEach var="a" items="${BOOKS}" setp="4">     <tr>         <c:forEach var="b" items="${BOOKS}" varStatus="status">             <c:if test="${status.index/4==0}">                 <td>                     <li></li>                     <li></li>                     <li></li>                 </td>             </c:if>         </c:forEach>        <c:forEach var="b" items="${BOOKS}" varStatus="status">            <c:if test="${status.index/4==1}">                <td>                     <li></li>                     <li></li>                     <li></li>                 </td>             </c:if>        </c:forEach>           <c:forEach var="b" items="${BOOKS}" varStatus="status">            <c:if test="${status.index/4==2}">                <td>                     <li></li>                     <li></li>                     <li></li>                 </td>             </c:if>        </c:forEach>        <c:forEach var="b" items="${BOOKS}" varStatus="status">            <c:if test="${status.index/4==3}">                <td>                     <li></li>                     <li></li>                     <li></li>                 </td>             </c:if>        </c:forEach>     </tr></c:forEach>不知道对不对建议用div,省事方便,table布局不多了吧
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java