<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<html>
<body>
图书信息查询<br><br>
<form action="/jstl_1/queryResult.jsp" >
请输入图书的模糊信息:<br>
<input name="bookname" type="text">
<input type="submit" value="查询">
</form>
<br>
<%
// String name=(String)session.getAttribute("sname");
String bookname=request.getParameter("bookname");
String sname=new String(bookname.getBytes("ISO-8859-1"));
%>
<!-- 配置数据源 -->
<sql:setDataSource driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/zhj?useUnicode=true&characterEncoding=gb2312"
user="root"
password="aaa123" scope="session"/>
<sql:query var="result" >
select BOOKID,BOOKNAME,BOOKPRICE from T_BOOK where BOOKNAME=?
<sql:param value="<%=sname %>"></sql:param>
</sql:query>
<table bgcolor="grey" border="1">
<tr>
<td>BOOKID</td>
<td>BOOKNAME</td>
<td>BOOKPRICE</td>
</tr>
<c:forEach items="${result.rows}" var="book">
<c:if test="${book.BOOKPRICE>50}">
<tr>
<td>${book.BOOKID}</td>
<td><font color=yellow>${book.BOOKNAME}</font></td>
<td>${book.BOOKPRICE}</td>
</c:if>
<c:if test="${book.BOOKPRICE<=50}">
<tr>
<td>${book.BOOKID}</td>
<td>${book.BOOKNAME}</td>
<td>${book.BOOKPRICE}</td>
</tr>
</c:if>
</c:forEach>
</table>
</body>
</html>