编程新手和这个网站。我当前的 .jsp 是
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ page import="java.sql.*"
import="action.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Here is your videogame!</title>
</head>
<BODY>
<H1>The Videogame Database Table </H1>
<%
Connection c = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/videogamesdb", "root", "password");
//instantiating a SQL statement
Statement statement = c.createStatement();
String sql = "SELECT * FROM videogamedetails";
ResultSet resultset =
statement.executeQuery(sql) ;
%>
<TABLE BORDER="1">
<TR>
<TH>Name</TH>
<TH>Genre</TH>
<TH>Developer</TH>
<TH>Rating</TH>
</TR>
<% while(resultset.next()) {%>
<TR>
<TD> <%= resultset.getString("vidgameName") %></TD>
<TD> <%= resultset.getString("vidgameGenre") %></TD>
<TD> <%= resultset.getString("vidgameDev") %></TD>
<TD> <%= resultset.getInt("vidgameRating") %></TD>
</TR>
<% } %>
</TABLE>
</BODY>
</HTML>
我相当确定我需要使用“SELECT * FROM videogamedetails WHERE vidgameName = p_Name”,但我不确定如何让 p_Name 成为用户搜索的内容。谢谢!