因此,我再次陷入困境,这是我的 .JSP 页面代码,我在其中尝试单击艺术家姓名,它将显示他们出现的电影。我在第一个查询中一切正常,但是当我到达在 queryMovies 中,我尝试将电影的标题链接回电影 ID,这应该带我到另一个页面,我得到错误 mid cannot be resolve to a variable。我究竟做错了什么?谢谢。
<html>
<head>
<%@ include file="header.htm" %>
<%@ page import="java.sql.*" %>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
String cs="jdbc:mysql://localhost:3306/hunters?user=root&password=password";
Connection cxn = DriverManager.getConnection(cs);
Statement stm = cxn.createStatement();
int oscar = 0;
String fname = request.getParameter("fname");
String lname = "", dob = "", nation = "", imdb = "", url = "", newaid = "", title = "", studio = "", role = "", rlsdate = "";
String queryArtist = "SELECT * FROM artist WHERE aid = '" + request.getParameter("selectedName") + "';";
ResultSet rsArtist = stm.executeQuery(queryArtist);
rsArtist.next();
fname = rsArtist.getString("fname");
lname = rsArtist.getString("lname");
dob = rsArtist.getString("dob").substring(0,4);
nation = rsArtist.getString("nation");
imdb = rsArtist.getString("imdb");
url = rsArtist.getString("url");
%>
<title><%= fname %> <%= lname %></title>
<h2><FONT COLOR="B22222"><%= fname%> <%= lname%></FONT></h2>
<p>Born in: <%= dob%></p>
<p>Nationality: <%= nation%></p>
<p>IMDB Bio: <a href="http://www.imdb.com/name/<%= imdb%>/" target="_blank">http://www.imdb.com/name/<%= imdb%>/</a></p>
<%
if (url == null)
{
out.println("<br />");
}
else
{
out.println("Website: <a href=" + url + "target=_blank>" + url + "</a><br>");
}
%>
<hr />
<h3><FONT COLOR="B22222">Filmography</FONT></h3>
<%
newaid = request.getParameter("selectedName");
String queryMovies = "SELECT * FROM artist, movies, artistmovie WHERE artistmovie.mid = movies.mid AND artist.aid = artistmovie.aid AND artist.aid = '";
queryMovies += request.getParameter("selectedName") + "';";
ResultSet rsMovies = stm.executeQuery(queryMovies);
while(rsMovies.next())
{
title = rsMovies.getString("title");
studio = rsMovies.getString("studio");
rlsdate = rsMovies.getString("rlsdate");
role = rsMovies.getString("role");
oscar = rsMovies.getInt("oscar");
mid = rsMovies.getInt("mid");
out.println("<tr><td> </td><td><a href= artistmovie.jsp?SelectedTitle=" + mid + ">" + title + " <a/></td>");
out.println("<td> </td><td>(" + studio + "</a></td>");
out.println("<td></td><td>" + rlsdate + ")</td>");
out.println("<td> </td><td>" + role + "</td></br></br>");
}
if (oscar == 0)
{
out.println("<td> </td><td><br /></td>");
}
else
{
out.println("<td> </td><td>Won oscar</td></tr>");
}
%>
<%@ include file="footer.htm" %>
</body>
</html>