[問題] 關於JSP
有問題要請問大家了= =a
我利用jsp和access裡面的table產生連結
可是網頁裡面下拉式表單的值(D1) 卻怎麼也傳不進去
以下先po出程式碼好了
<%@page import="java.sql.*" contentType="text/html;charset=big5"%>
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>新增網頁1</title>
</head>
<body>
<%
String Place= request.getParameter("D1");
//由下拉式選單抓取數值
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:db1");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from P where name='"+Place+"'");
//很奇怪的地方,為什麼無法在這裡由資料庫抓取資料呢?
可是,如果把("select * from P where name='"+Place+"'")
直接指定成"select * from P where name='台北'")
那麼就會在螢幕上印出所要求的資訊
所以,請問一下各位這是不是在變數傳值的過程中發生問題?要怎麼解決呢?
%>
<TABLE bgcolor = DogerBlue>
<tr bgcolor = SkyBlue>
<TD><B>place</B><TD><B>火車</B><TD><B>飛機</B><TD><B>公車</B>
</TD>
</TR>
<%
while(rs.next()){
%>
<TR bdcolor = LightGoldenrodYellow>
<TD><B><%=rs.getString("name")%></B></TD>
<TD><B><%=rs.getInt("trainprice")%></B></TD>
<TD><B><%=rs.getInt("planeprice")%></B></TD>
<TD><B><%=rs.getInt("busprice")%></B></TD>
</TR>
<%
}//迴圈結束的地方
rs.close();
stmt.close();
con.close();
%>
</table>
<p> </p>
</body>
</html>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 163.22.18.97
討論串 (同標題文章)
以下文章回應了本文 (最舊先):
完整討論串 (本文為第 1 之 5 篇):