String querystring = "select items.name,items.image_url,items.author,items.translator,items.price,items.discount,items.notes from items where items.category_id='"+transitid+"')";干嘛多个右括号啊?String querystring = "select items.name,items.image_url,items.author,items.translator,items.price,items.discount,items.notes from items where items.category_id='"+transitid+"'";还有 1、out.print(transitid)会怎么样啊? 2、确保前面一个页面确实有传参数过来
这样做不行啊,我试了几十遍了。
如果不是别的错误的话!!!
你查看一下有没有其他的错误,不要怀疑这个的接受参数的能力。
你说它还需要别的定义吗?
我是直接用的 transitid 。
你能给我再介绍一下这个用法吗?
我String transitid=request.getParameter("transitid");
还是有点问题。
java.lang.NumberFormatException: null
String transitid=request.getParameter("transitid");就可以了。
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<html>
<head>
<title>按类显示结果</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<jsp:include page="header.jsp" flush="true"/>
<table width="100%" border="0" height="158" cellspacing="0" cellpadding="0">
<tr>
<td height="27">
<table width="100%" border="1" align="center" height="30" cellspacing="0" cellpadding="0" bordercolor="#FFFFFF">
<tr>
<td bgcolor="#336699" bordercolor="#CCCCCC" height="24">
<div align="center"><font color="#FFFFFF"><b>Recommended Titles</b></font></div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="189">
<table width="100%" border="1" height="109" bordercolor="#CCCCCC" cellspacing="0" cellpadding="0">
<%
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connect= DriverManager.getConnection("jdbc:odbc:bookserver","aa","hilda");
Statement stat = connect.createStatement();
String transitid=request.getParameter("transitid");
String querystring = "select items.name,items.image_url,items.author,items.translator,items.price,items.discount,items.notes from items where items.category_id='"+transitid+"')";
ResultSet result = stat.executeQuery(querystring);
while(result.next())
{
%>
<tr>
<td height="27" width="67%"><font size="5" color="#CC6633"><%=result.getString("name")%></font></td>
<td height="27" rowspan="5" width="33%">
<div align="center"><img src="<%=result.getString("image_url")%>" width="109" height="139" align="absmiddle"></div>
</td>
</tr>
<tr>
<td height="28" width="67%"><font color="#FF0000">author:</font> <%=result.getString("author")%></td>
</tr>
<tr>
<td height="30" width="67%"><font color="#FF0000">translator:</font><%=result.getString("translator")%></td>
</tr>
<tr>
<td height="29" width="67%"><font color="#FF0000">price:</font> <%=result.getFloat("price")%></td>
</tr>
<tr>
<td height="29" width="67%"><font color="#FF0000">discount:</font><%=result.getInt("discount")%></td>
</tr>
</table>
<div align="center"><br>
</div>
</td>
</tr>
</table>
<p>
<% }
result.close();
stat.close();
} //end try
catch(Exception e)
{
out.println(e.toString());
}
%>
</body>
</html>
1、out.print(transitid)会怎么样啊?
2、确保前面一个页面确实有传参数过来
java.lang.NumberFormatException: null没有参数传过来
out.println(category_id);
确定是否有值。
下个页面用
或者
<form action="next.jsp" method="post">
<input type="hidden" name="transitid" value=<%=transitid%>>
</form>