大家来帮我看看是什么问题?
<body>
<jsp:useBean id= "jndibean " class= "zs.JNDIBean " scope= "page "/>
<jsp:setProperty name= "jndibean " property= "* " />
<br> <br> <br>
<div align= "center ">
<h1> <font size= "6 " color= "#ff0000 "> <font face= "楷体_GB2312 "> 查询系统 </font> </font> </h1>
</div> <br> <br>
<table align= "center " width=80% border= "1 ">
<tr> <td> 学号 </td> <td> 姓名 </td> <td> 专业 </td> </tr>
<%
Connection conn1=jndibean.getConnection();
String sql1= "select * from T_TDD where KSH= ' "+(String) session.getAttribute( "username ")+ " ' ";
Statement stmt = conn1.createStatement();
ResultSet rs1=stmt.executeQuery(sql1);
while(rs1.next()){
String KSH=rs1.getString( "KSH ");
String XM=rs1.getString( "XM ");
String LQZY=rs1.getString( "LQZY ");
}
conn1.close();
Connection conn2=jndibean.getConnection();
String sql2= "select * from T_JHK where ZYDH=? ";
PreparedStatement pstmt = conn2.prepareStatement(sql2);
pstmt.setString(1, LQZY);
ResultSet rs2=pstmt.executeQuery();
while(rs2.next()){
String ZYMC=rs2.getString( "ZYMC ");
}
conn2.close();
%>
<tr>
<td> <%= KSH %> </td>
<td> <%= XM %> </td>
<td> <%= ZYMC %> </td>
</tr>
</table>
<p align= "center "> <a href= "index.jsp "> 返回上一页 </a> </p>
</body>
pstmt.setString(1, LQZY);中LQZY提示错误
<td> <%= KSH %> </td>
<td> <%= XM %> </td>
<td> <%= ZYMC %> </td>
中KSH,XM,ZYMC提示错误,怎么回事?
------解决方案--------------------它们都是局部变量 所以出错了
你可以把它们的定义都写在外面
------解决方案--------------------你可以在外面写个
String KSH= " ";
String ....
KSH=rs1.getString( "KSH ");