跪求把下面的代码改成JSTL的~差不多就行
发布网友
发布时间:2022-12-01 05:16
我来回答
共1个回答
热心网友
时间:2023-11-06 09:21
楼主验货!!累死了
<%@ page language="java" pageEncoding="GBK" contentType="text/html;charset=gkb"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>欢迎选购商品</title>
<link href="css.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<script src = "js.js"> </script>
<!-- EL表达式 -->
欢迎您,用户${requestScope.name }
<form id="form2" name="form2" method="get" action="SearchList.jsp">
<input type="text" name="orderid" /><input type="button" name="button" value="输入订单号查询订单" onclick="search()"/>
<b>*您只能查询到您的账号购买的订单 </b>
</form>
<form id="form1" name="form1" method="get" action="CartList.jsp">
<table class="c2" border="1px">
<tr class="c1">
<th width="150px">图书名称</th>
<th width="150px">ISBN</th>
<th width="150px">作者</th>
<th width="150px">出版社</th>
<th width="50px">定价</th>
<th width="50px">折扣</th>
<th width="50px">折扣价</th>
<th width="150px">购买</th>
</tr>
<!-- 把这段代码写到一个类里,要么用脚本括起来: -->
<!--
MODEL.model.getConn();
ResultSet rs=MODEL.model.Serch("select * from books order by bookid");
List list = new ArrayList();
while(rs.next){
//封装实体
list.add(实体对象);
}
request.setAttribute("list",list);
记得使用请求转发
-->
<c:forEach var="book" items="${requestScope.list }" >
<tr>
<td>${ book.bookname}</td>
<td>${book.ISBN}</td>
<td>${book.author}</td>
<td>${book.publisher}</td>
<td>${book.bookprice}</td>
<td>${ book.discount}</td>
<td>${bookprice*discount }</td>
<c:if test="${sessionScope.select != null }">
<c:forEach var="select" items="${sessionScope.select }" varStatus="array">
<c:if test="${select eq book.bookid }">
<td><input name="select" type="checkbox" value="${book.bookid }"checked="checked"/>装入购物车</td>
</c:if>
<c:if test=" ${array.count+1 == fn:length(sessionScope.select)}">
<td><input name="select" type="checkbox" value="${book.bookid }"/>装入购物车</td>
</c:if>
</c:forEach>
</c:if>
<c:if test="${sessionScope.select == null }">
<td><input name="select" type="checkbox" value="${book.bookid }"/>装入购物车</td>
</c:if>
</tr>
</c:forEach>
</table>
<br><input type="button" name="Submit" value="进入购物车" onclick="check()"/> </form>
</body>
</html>追问可以加qq么 ①③③零③③⑦②②⑧
追答已加