<form action="check.jsp" method="post">
选择用户编号:
<select name="users" >
<option value="1"> 1程序设计 </option>
<option value="2"> 2网络维护 </option>
<option value="3"> 3多媒体设计 </option>
</select>
<input type="submit" name="submit" value="提交" />
</form>
那么在下个页面check.jsp中,应该String BType=request.getParameter("value");还是
String BType=request.getParameter("users");还是其它方法才对????
试试不就知道了
<html>
<body>
<%
try
{
String accessfile = "D:/AccessFile/bookshop.mdb";
String dbname = "";
String user = "";
String url ="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+accessfile;
//加载驱动程序
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//建立连接
Connection conn= DriverManager.getConnection(url);
//创建语句对象
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String BType=request.getParameter("users");
String sql="select * from BookInfo where BType='"+BType+"'";
ResultSet rs=stmt.executeQuery(sql);
//连接数据库,检查是否为合法用户
//直接用路径访问access文件
if(rs.next()){
//String BId=rs.getString("BId");
//String BName = rs.getString("BNmae");
//String Price = rs.getString("Price");
//session.setAttribute("BName", BName);
//session.setAttribute("Price", Price);
String BType_sql = rs.getString("BType");
if(BType_sql.equals("1"))
{
String BookListBName = rs.getString("BName");
String PriceList = rs.getString("Price");
session.setAttribute("permitted","yes");
response.sendRedirect("type1.jsp");
}else if(BType_sql.equals("2"))
{
session.setAttribute("permitted","yes");
response.sendRedirect("type2.jsp");
}
else
{
session.setAttribute("permitted","yes");
response.sendRedirect("type3.jsp");
}
conn.close();
}
}catch(Exception e){
out.print("连接数据库错误!<br>");
out.print(e.getMessage());
}
%>
</body>
</html>