mid无法解析为变量

时间:2012-04-17 15:49:03

标签: html jsp

所以我再次陷入困境这是我的.JSP页面的代码,我试图点击一个艺术家名称,它会显示他们出现的电影。我在第一个查询中有所有工作但是当我到了queryMovies,在那里我尝试将电影的标题href回到电影ID,这应该带我到另一个页面,我得到错误mid无法解析为变量。我究竟做错了什么?感谢。

    <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>&nbsp;</td><td><a href= artistmovie.jsp?SelectedTitle=" + mid + ">" + title + " <a/></td>");
    out.println("<td>&nbsp;&nbsp;&nbsp;</td><td>(" + studio + "</a></td>"); 
    out.println("<td></td><td>" + rlsdate + ")</td>");  
    out.println("<td>&nbsp;&nbsp;</td><td>" + role + "</td></br></br>");

}
if (oscar == 0)
{
    out.println("<td>&nbsp;</td><td><br /></td>");
}
else
{
    out.println("<td>&nbsp;</td><td>Won oscar</td></tr>");
}
%>
<%@ include file="footer.htm" %>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

更改

out.println("<tr><td>&nbsp;</td><td><a href= artistmovie.jsp?SelectedTitle=" + mid + ">" + title + " <a/></td>");

out.println("<tr><td>&nbsp;</td><td><a href=\"artistmovie.jsp?SelectedTitle="+ mid +"\">" + title + " <a/></td>");

应该有用。

除此之外

out.println("<td>&nbsp;&nbsp;&nbsp;</td><td>(" + studio + "</a></td>"); 

你在哪里开始以“<a>”结尾的“<td>”标签。