想要的效果:在一个JSP页面中实现查询数据库并显示查询信息的功能?
已经实现的功能有:点击链接实现不同的查询
但是,我不能从列表中获得列表的值
也就是说,怎么样才能同时把列表的值和超链接的值用list传出去?
请前辈们指点一下。谢谢了哈<%@ page contentType="text/html; charset=UTF-8"
import="dao.*,java.util.List"
%>
<%
request.setCharacterEncoding("UTF-8");
int type;
if(request.getParameter("type")==null)
{
type=0;
}else
{
type=new Integer(request.getParameter("type"));//获得商品类型
}
String item=request.getParameter("show");//获得排序设定List list=new StorageBiz().listshop(type,item);//调用查询商品方法
%>
<html>
<head>
<link href="style/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div>
<table>
<tr>
<td width="150"><a href="index.jsp">全部</a></td>
<td width="150"><a href="index.jsp?type=1">电器</a></td>
<td width="150"><a href="index.jsp?type=2">食品</a></td>
<td width="150"><a href="index.jsp?type=3">服装</a></td>
<td width="150"><a href="index.jsp?type=4">日用品</a></td>
<td width="228">排序方式:
<select name="show">
<option selected>-------</option>
<option value="Name">名称</option>
<option value="Price">价格</option>
<option value="number">数量</option>
<option value="makeTime">生产日期</option>
</select></td>
</tr>
</table>
</div>
<div><table border="0">
<tr>
<td colspan="6" class="head">查询结果</td>
</tr>
<tr>
<td>商品名</td>
<td>单价(元)</td>
<td>数量</td>
<td>类型</td>
<td>保质期(天)</td>
<td>生产日期</td>
</tr>
<%
for(int i=0;i<list.size();i++)
{
Storage sto=(Storage)list.get(i);
%>
<tr>
<td><%=sto.getName() %></td>
<td><%=sto.getPrice() %></td>
<td><%=sto.getnumber() %></td>
<td><%=sto.gettype() %></td>
<td><%=sto.getuseDay() %></td>
<td><%=sto.getmakeTime() %></td>
</tr>
<%
}
%>
</table>
</div>
</body>
</html>
已经实现的功能有:点击链接实现不同的查询
但是,我不能从列表中获得列表的值
也就是说,怎么样才能同时把列表的值和超链接的值用list传出去?
请前辈们指点一下。谢谢了哈<%@ page contentType="text/html; charset=UTF-8"
import="dao.*,java.util.List"
%>
<%
request.setCharacterEncoding("UTF-8");
int type;
if(request.getParameter("type")==null)
{
type=0;
}else
{
type=new Integer(request.getParameter("type"));//获得商品类型
}
String item=request.getParameter("show");//获得排序设定List list=new StorageBiz().listshop(type,item);//调用查询商品方法
%>
<html>
<head>
<link href="style/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div>
<table>
<tr>
<td width="150"><a href="index.jsp">全部</a></td>
<td width="150"><a href="index.jsp?type=1">电器</a></td>
<td width="150"><a href="index.jsp?type=2">食品</a></td>
<td width="150"><a href="index.jsp?type=3">服装</a></td>
<td width="150"><a href="index.jsp?type=4">日用品</a></td>
<td width="228">排序方式:
<select name="show">
<option selected>-------</option>
<option value="Name">名称</option>
<option value="Price">价格</option>
<option value="number">数量</option>
<option value="makeTime">生产日期</option>
</select></td>
</tr>
</table>
</div>
<div><table border="0">
<tr>
<td colspan="6" class="head">查询结果</td>
</tr>
<tr>
<td>商品名</td>
<td>单价(元)</td>
<td>数量</td>
<td>类型</td>
<td>保质期(天)</td>
<td>生产日期</td>
</tr>
<%
for(int i=0;i<list.size();i++)
{
Storage sto=(Storage)list.get(i);
%>
<tr>
<td><%=sto.getName() %></td>
<td><%=sto.getPrice() %></td>
<td><%=sto.getnumber() %></td>
<td><%=sto.gettype() %></td>
<td><%=sto.getuseDay() %></td>
<td><%=sto.getmakeTime() %></td>
</tr>
<%
}
%>
</table>
</div>
</body>
</html>
LZ可以把要求再具体些 大家帮助你就会方便些
第二个 不在要求范畴之内 你可以另启一个帖(通过SQL语句进行排序)我们先说说第一个 还记得我1L说的么? 实际上不一定非得通过a href 进行重定向 你可以通过在a标签上也加onclick事件 然后到JS函数中的话 根据当前下拉选中的值 拼URL 然后执行跳转
通过URL传就行 如果查询条件不多的话不一定非得用表单
请问怎么用url传啊?
就是通过链接传 GET方式传..(你目前href的传参方式)