String getSname=request.getParameter("singer");
String sname="'"+getSname+"'";
String query=" SELECT singer FROM egypt WHERE singer= ' "+getSname+" ' ";
rs=stmt.executeQuery(query);
while(rs.next()) {
out.print("<br>singer : " + rs.getString ("singer") );
当我在页面中输入代码时,jsp在运行程序时出现相同的代码
答案 0 :(得分:1)
可能会导致问题。
getSname
附近添加两次单引号。 getSname
附近添加了空格。再看一下代码。
String sname="'"+getSname+"'"; // Single quote here
// again single quote is added here along with spaces around it
String query=" SELECT singer FROM egypt WHERE singer= ' "+getSname+" ' ";