Home > front end >  Turn to help have a look at the great god, the JSP page foreach no output, what reason be
Turn to help have a look at the great god, the JSP page foreach no output, what reason be

Time:12-28

The JSP page

<% @ page language="Java" import="Java. Util. *" pageEncoding="utf-8" % & gt;
<% @ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" % & gt;
<% @ page import="com. Model. Home" % & gt;
<%
String path=request. GetContextPath ();
String=basePath request. GetScheme () + "://" + request. GetServerName () + ":" + request. GetServerPort () + + "/" path;
% & gt;




My JSP 'index. The JSP' starting page
<meta HTTP - equiv="pragma" content="no - cache" & gt;
<meta HTTP - equiv="cache-control" content="no - cache" & gt;
<meta HTTP - equiv="expires" content="0" & gt;
<meta HTTP - equiv="keywords" content="keyword1, keyword2, keyword3 & gt;"
<meta HTTP - equiv="description" content="This is my page" & gt;
<link rel="stylesheet" type="text/CSS" href="https://bbs.csdn.net/topics/styles.css" & gt;
- & gt;


<body>

& NBSP & amp; Nbsp

The dormitory door & lt;/th>
The dormitory in campus & lt;/th>
Dormitory detailed address & lt;/th>
Dormitory contact number & lt;/th>
Dormitory number & lt;/th>
Dormitory status & lt;/th>


The ${home. GetId ()} & lt;/td>
The ${home. GetHomeNum ()} & lt;/td>
The ${home. GetAddress ()} & lt;/td>
The ${home. GetDetaileAddress ()} & lt;/td>
The ${home. GetTel ()} & lt;/td>
The ${home. GetNum ()} & lt;/td>
The ${home. GetStatus ()} & lt;/td>






This is the Servlet code page
Public void doGet (it request, HttpServletResponse response)
Throws ServletException, IOException {

Request. SetCharacterEncoding (" utf-8 ");
HomeDao dao=new homeDao ();
ArrayList Homes=dao. GetAll ();
Request. SetAttribute (" homes ", homes);
Request. GetRequestDispatcher (" index. The JSP "). The forward (request, response);
}

This is the database query method
Public ArrayList The getAll () {
String SQL="select * from tb_home";
Try {
Conn=DBHelper. GetConn ();
PST=conn. PrepareStatement (SQL);
Rs=PST. ExecuteQuery ();
{if (rs. Next ())
Home Home=new Home ();
Home. SetHomeNum (rs. Get string (" homeNum "));
Home. SetAddress (rs. Get string (" address "));
DetaileAddress home. SetDetaileAddress (rs. Get string (" "));
Home. SetTel (rs. Get string (" tel "));
Home. SetNum (rs. Get int (" num "));
Home. SetStatus (rs. Get int (" status "));
Homes. The add (home);
}
} the catch (SQLException e) {
e.printStackTrace();
} the finally {
DBHelper. CloseAll (rs, PST, conn);
}
Return homes;
}

This is a web page output

  • Related