处理结果集为什么取不出对象呢?添加断点看了一下,处理结果集遍历那部分直接跳过去了?实在是不懂了
public class DeptEditServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String contextPath = request.getContextPath();
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.print("<!DOCTYPE html>") ;
out.print("<html lang='en'>");
out.print("<head>");
out.print("<meta charset='UTF-8'>");
out.print("<title>修改部门</title>" );
out.print("</head>");
out.print("<body>");
out.print("修改部门
");
out.print("
");
out.print("<form action='"</span>+contextPath+<span class="hljs-string">"/dept/modify' method='post'>");
//获取部门编号
String deptno = request.getParameter("deptno");
Connection conn =null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conn = DBUtil.getConnection();
String sql = "select dname,loc from dept where deptno = ?";
ps = conn.prepareStatement(sql);
ps.setString(1,deptno);
rs = ps.executeQuery();
if(rs.next()){
String dname = rs.getString("dname");
String loc = rs.getString("loc");
out.print("部门编号<input type='text' name='deptno' value='"</span>+deptno+<span class="hljs-string">"' readonly />
");
out.print("部门名称<input type='text' name='dname' value='"</span>+dname+<span class="hljs-string">"'/>
");
out.print("部门位置<input type='text' name='loc' value='"</span>+loc+<span class="hljs-string">"'/>
");
}
} catch (SQLException e) {
e.printStackTrace();
}finally {
DBUtil.close(conn,ps,rs);
}
out.print("<input type='submit' value='修改'>
");
out.print("</form>");
out.print("</body>");
out.print("</html>");
}
}
浏览器那部分该展示的部分也没有显示
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/609105121066194.png "#left")