我有一个案例,我必须得到所有下拉元素的总数。我能够单独实现它。以下是适用于个人选择的代码。
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body><form name="Reports" method="post" action="Reports.jsp"><table><tr><td>
Select user:<select name="user" id="user">
<option value="">Select User</option>
<option value="Rakesh">Rakesh</option>
<option value="Hari">Hari</option>
</select></td><td>
Select Type:<select name="type" id="type">
<option value="'Updates','Multibases','DAIS','Acds','Legis','LegAll'">All</option>
<option value="Updates">Updates</option>
<option value="Multibases">Multibases</option>
<option value="DAIS">DAIS</option>
<option value="Acds">Admin Codes</option>
<option value="Legis">Legis</option>
<option value="LegAll">Legis-All</option>
</select></td>
<td><input type="submit" value="Generate" id="sub1" name="sub1"></td></tr>
</table> </form> </body>
jsp在下面
<%--
Document : Reports
Created on : Oct 25, 2012, 4:53:23 PM
Author : u0138039
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="DBCon.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body><table>
<%
String[] a=request.getParameterValues("type");
String b=request.getParameter("user");
try{
ps=con.prepareStatement("Select * from Scope1");
ps=con.prepareStatement("SELECT SUM(Update_Count) FROM Scope1 where type ='"+a+"' and Specialist='"+b+"'");
rs=ps.executeQuery();
while(rs.next())
{%>
<tr>
<td><%=a%>:</td><td>
<%=rs.getString(1)%>
</td></tr>
<% }
}
catch(Exception e)
{
out.println(e);
}
%>
并从下拉列表中检索所有值,我使用下面的 sql 代码
SELECT SUM(Update_Count) FROM Scope1 where type IN ('All','Updates','Multibases','DAIS','Acds','Legis','LegAll') and Specialist='b';
并单独检索我使用下面的代码
ps=con.prepareStatement("SELECT SUM(Update_Count) FROM Scope1 where type IN ('"+a+"') and Specialist='"+b+"'");
我希望这在单个语句中,并且我希望在全选时以表格格式显示输出。
谢谢